How can I send multiple attachments in email using VB.NET
35 pts.
0
Q:
How can I send multiple attachments in email using VB.NET


I am working on a code which is used to send email from the desktop application, it works fine.
The main problem arises when i tried to attach multiple files or i tried to attach a heavy file (e.g. 1 Mb, or higher)
Below is the code i have used.




For i As Integer = 0 To Me.dgvMail.Rows.Count - 1
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential(EId, Pwd)
SmtpServer.Port = PortNo
SmtpServer.Host = Smtp
mail = New MailMessage()
mail.From = New MailAddress(EId)
mail.To.Add(Trim(Me.dgvMail(0, i).Value))
mail.Subject = Trim(Me.txtMailHeader.Text)
mail.Body = Trim(Me.txtEmail.Text)
'' code to attach the attachment in the mail '''''''''''''''''
For Counter As Integer = 0 To lstAttachment.Items.Count - 1
Attachment = New System.Net.Mail.Attachment(lstAttachment.Items(Counter))
mail.Attachments.Add(Attachment)
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''' to get the mail sending fail notification
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
mail.Priority = MailPriority.High
'************************************************************
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
Next
ASKED: Jun 13 2009  7:39 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
35 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Last Answered: Jun 13 2009  7:39 AM GMT by Honeyprogrammer   35 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0