本文介绍了如何在VB.NET中附加一个或两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的先生, 我有两种类型的文件要附加在同一个男性中,假设一个是A,第二个是B但A& B从来没有相同的数量,但邮件应该根据A 我尝试过: Sub SendEmailObligation() Application.DisplayAlerts = 错误 Application.ScreenUpdating = 错误 工作簿( Auto Mail Schedule.xls)。激活表格( 客户邮件)。选择 对于 i = 2 要范围( a1)。SpecialCells(xlCellTypeLastCell)。 AttachFileName1 = Cells(i, 5 )。价值&单元格(i, 6 )。值 AttachFileName2 = Cells(i, 5 )。 &安培;单元格(i, 7 )。值 如果 Dir(AttachFileName1)< ;> 然后 ' 和Dir(AttachFileName2)<> 然后 ESubject = Cells(i, 3 )。值& 交货日期的交换义务报告&格式$(日期 + 1 , MMMM dd,yyyy)& 。 SendTo = Cells(i, 1 )。值 CCTo = Cells(i, 2 )。值 Ebody = 亲爱的先生/女士,& Chr( 10 )& Chr( 10 )& _ 请查找当天的附加交换结果。& Chr( 10 )& Chr( 10 )& _ Chr( 10 )& Chr( 10 )& 此处附有义务报告。 _ & Chr( 10 )& Chr( 10 )& Thanks& Regards, _ & Chr( 10 )& Chr( 10 )& GMRETL控制室 _ & Chr( 10 )& 新的Shakti Bhawan,对面的ATS综合体 _ & Chr( 10 )& IGIA New Delhi-110037 _ & Chr( 10 )& 电话:关:011-49883320,传真:关:011-49882255 / 49883331 _ 设置 App = CreateObject( Outlook.Application) 设置 Itm = App.CreateItem( 0 ) 使用 Itm .Subject = ESubject 。 To = SendTo .CC = CCTo .Body = Ebody .Attachments.Add(AttachFileName1) .Attachments.Add(AttachFileName2)' 必须是完整路径 。保存 ' 。发送 结束 使用 设置 App = 没有 设置 Itm = 没什么 结束 如果 下一步 MsgBox( 所有客户邮件准备好发送!!! ) 结束 Sub 解决方案 (日期 + 1 , MMMM dd,yyyy)& 。 SendTo = Cells(i, 1 )。值 CCTo = Cells (i, 2 )。值 Ebody = 亲爱的Sir / Ma'am,& Chr( 10 )& Chr( 10 )& _ 请查找当天的附加交换结果。 & Chr( 10 )& Chr( 10 )& _ Chr( 10 )& Chr( 10 )& 此处附有义务报告。 _ & Chr( 10 )& Chr( 10 )& Thanks& Regards, _ & Chr( 10 )& Chr( 10 )& GMRETL控制室 _ & Chr( 10 )& 新的Shakti Bhawan,对面的ATS综合体 _ & Chr( 10 )& IGIA New Delhi-110037 _ & Chr( 10 )& 电话:关:011-49883320,传真:关:011-49882255 / 49883331 _ 设置 App = CreateObject( Outlook.Application) 设置 Itm = App.CreateItem( 0 ) 使用 Itm .Subject = ESubject 。 To = SendTo .CC = CCTo .Body = Ebody .Attachments.Add(AttachFileName1) .Attachments.Add(AttachFileName2)' 必须是完整路径 。保存 ' 。发送 结束 使用 设置 App = 没有 设置 Itm = 没什么 结束 如果 下一步 MsgBox( 所有客户邮件准备好发送!!! ) 结束 Sub Dear Sir,I have two type of files to be attached in same male, let's say one is A and second is B but A & B never in the same quantity but mail should be prepared according to AWhat I have tried:Sub SendEmailObligation()Application.DisplayAlerts = FalseApplication.ScreenUpdating = FalseWorkbooks("Auto Mail Schedule.xls").ActivateSheets("Client mail").SelectFor i = 2 To Range("a1").SpecialCells(xlCellTypeLastCell).RowAttachFileName1 = Cells(i, 5).Value & Cells(i, 6).ValueAttachFileName2 = Cells(i, 5).Value & Cells(i, 7).ValueIf Dir(AttachFileName1) <> "" Then 'And Dir(AttachFileName2) <> "" ThenESubject = Cells(i, 3).Value & " Exchange Obligation Report for Delivery Date " & Format$(Date + 1, "MMMM dd, yyyy") & "."SendTo = Cells(i, 1).ValueCCTo = Cells(i, 2).ValueEbody = "Dear Sir/Ma'am," & Chr(10) & Chr(10) & _"Kindly find the attached exchange result for the day." & Chr(10) & Chr(10) & _Chr(10) & Chr(10) & "The obligation reports are also attached herewith." _& Chr(10) & Chr(10) & "Thanks & Regards," _& Chr(10) & Chr(10) & "GMRETL Control Room" _& Chr(10) & "New Shakti Bhawan,Opposite ATS complex" _& Chr(10) & "IGIA New Delhi-110037 " _& Chr(10) & "Phone: Off: 011-49883320,Fax: Off: 011-49882255/49883331 " _Set App = CreateObject("Outlook.Application")Set Itm = App.CreateItem(0)With Itm.Subject = ESubject.To = SendTo.CC = CCTo.Body = Ebody.Attachments.Add (AttachFileName1).Attachments.Add (AttachFileName2) ' Must be complete path.Save'.SendEnd WithSet App = NothingSet Itm = NothingEnd IfNextMsgBox ("All Clients mails Ready to be Sent!!! ")End Sub 解决方案 (Date + 1, "MMMM dd, yyyy") & "."SendTo = Cells(i, 1).ValueCCTo = Cells(i, 2).ValueEbody = "Dear Sir/Ma'am," & Chr(10) & Chr(10) & _"Kindly find the attached exchange result for the day." & Chr(10) & Chr(10) & _Chr(10) & Chr(10) & "The obligation reports are also attached herewith." _& Chr(10) & Chr(10) & "Thanks & Regards," _& Chr(10) & Chr(10) & "GMRETL Control Room" _& Chr(10) & "New Shakti Bhawan,Opposite ATS complex" _& Chr(10) & "IGIA New Delhi-110037 " _& Chr(10) & "Phone: Off: 011-49883320,Fax: Off: 011-49882255/49883331 " _Set App = CreateObject("Outlook.Application")Set Itm = App.CreateItem(0)With Itm.Subject = ESubject.To = SendTo.CC = CCTo.Body = Ebody.Attachments.Add (AttachFileName1).Attachments.Add (AttachFileName2) ' Must be complete path.Save'.SendEnd WithSet App = NothingSet Itm = NothingEnd IfNextMsgBox ("All Clients mails Ready to be Sent!!! ")End Sub 这篇关于如何在VB.NET中附加一个或两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-01 21:47