2010-08-28 60 views
1

我正在使用以下代碼發送帶附件的電子郵件。我可以發送一個附件,但我怎樣才能發送多個附件?電子郵件中的多個文件附件

Dim vrAttachFilePath As String = "c:\users\ittahad\documents\abc.doc" 
If vrAttachFilePath.Length > 0 Then 
    oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePath)) 
End If 

回答

3

把很簡單:

Dim vrAttachFilePathFile1 As String = "c:\users\ittahad\documents\abc.doc" 
Dim vrAttachFilePathFile1 As String = "c:\users\ittahad\documents\def.doc" 

oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePathFile1)) 
oMail.Attachments.Add(New Net.Mail.Attachment(vrAttachFilePathFile2)) 

你可以通過調用Attachments.Add每次只要你想簡單地添加儘可能多的附件附件。

2

你可以多元素添加到Attachments集合:

oMail.Attachments.Add(New Net.Mail.Attachment(path1)) 
oMail.Attachments.Add(New Net.Mail.Attachment(path2)) 
oMail.Attachments.Add(New Net.Mail.Attachment(path3)) 
...