Sending Multiple Attachment from VB.net Mail Class
Public Sub MailData(ByVal Path As String, ByVal strEmailID As String, _
ByVal strEmailCC As String, ByVal strEmailBCC As String,
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "", _
Optional ByVal KillPath As Boolean = True)
Dim msg As New MailMessage
Dim arrPath() As String
arrPath = Path.Split(";")
msg.From = New MailAddress(xyz@abc.com)
msg.To.Add("abc@123.co.in")
msg.CC.Add("switinkotian@rediffmail.com")
msg.Bcc.Add("switinkotian@gmail.com")
msg.Subject = "Attached is a Mulitple PDF file"
msg.Body = "Developed by - Switin Kotian"
'Dim attachment As Attachment = New Attachment(Path) ' inCase of Multiple Single Attachment
Dim attachment As Attachment
For icnt As Integer = 0 To arrPath.Length - 1
attachment = New Attachment(arrPath(icnt))
msg.Attachments.Add(attachment)
Next
Dim SMTPMail As SmtpClient = New SmtpClient(SMTPAddress, GrpSetup.PortNo)
Dim SMTPUserInfo As System.Net.NetworkCredential = New
System.Net.NetworkCredential(strSMTPUser, strSMTPPwd)
SMTPMail.UseDefaultCredentials = False
SMTPMail.DeliveryMethod = SmtpDeliveryMethod.Network
SMTPMail.Credentials = SMTPUserInfo
'SMTPMail.Timeout = 0
Try
SMTPMail.Send(msg)
Catch ex As Exception
End Try
End Sub
ByVal strEmailCC As String, ByVal strEmailBCC As String,
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "", _
Optional ByVal KillPath As Boolean = True)
Dim msg As New MailMessage
Dim arrPath() As String
arrPath = Path.Split(";")
msg.From = New MailAddress(xyz@abc.com)
msg.To.Add("abc@123.co.in")
msg.CC.Add("switinkotian@rediffmail.com")
msg.Bcc.Add("switinkotian@gmail.com")
msg.Subject = "Attached is a Mulitple PDF file"
msg.Body = "Developed by - Switin Kotian"
'Dim attachment As Attachment = New Attachment(Path) ' inCase of Multiple Single Attachment
Dim attachment As Attachment
For icnt As Integer = 0 To arrPath.Length - 1
attachment = New Attachment(arrPath(icnt))
msg.Attachments.Add(attachment)
Next
Dim SMTPMail As SmtpClient = New SmtpClient(SMTPAddress, GrpSetup.PortNo)
Dim SMTPUserInfo As System.Net.NetworkCredential = New
System.Net.NetworkCredential(strSMTPUser, strSMTPPwd)
SMTPMail.UseDefaultCredentials = False
SMTPMail.DeliveryMethod = SmtpDeliveryMethod.Network
SMTPMail.Credentials = SMTPUserInfo
'SMTPMail.Timeout = 0
Try
SMTPMail.Send(msg)
Catch ex As Exception
End Try
End Sub
Comments
Post a Comment