Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am working in Newspaper publishing house. Our company need to send the receipt through email attachment. Currently we export the receipt in pdf format using report viewer one by one. and also pdf file name is Reportviewer.pdf. We also need the file name followed by receipt no. like 10000.pdf

My issue is how to send multiple email with attachment in asp.net.

pls advice me.

Thank you
Posted

VB
Smtp_Server.UseDefaultCredentials = False
       Smtp_Server.Credentials = New Net.NetworkCredential("mymail@gmail.com", "mailPassword")
       Smtp_Server.Port = 587
       Smtp_Server.EnableSsl = True
       Smtp_Server.Host = "smtp.gmail.com"
       Dim path As String="D:\filesToMail\"     
       e_mail = New MailMessage()
       e_mail.From = New MailAddress(mymail@gmail.com)     
       Dim dir As New DirectoryInfo(path)     
       Dim filesInDirectory As FileInfo() = di.GetFiles() 
       ForEach file in filesInDirectory
         attach = New System.Net.Mail.Attachment(file.FullName)
         e_mail.Attachments.Add(attach)
       Next   
       e_mail.To.Add(txtTo)
       e_mail.Subject = txtsubject.Text
       e_mail.IsBodyHtml = False
       e_mail.Body = txtBody   
       Smtp_Server.Send(e_mail)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900