How to send mail with attachments in ASP.net
-
Hi Friends how can i send Email with files attached in asp.net by opening a file dialog when ADD button is clicked Thanks in advance
I would imagine that if you're sending the mail from the server, you need to select files one at a time with the file dialog and copy them to the server. Otherwise, use a mailto tag and let users attach files in outlook. Unless the file is on the server already, then you don't need the file dialog, you need your own list of files. Christian Graus - Microsoft MVP - C++
-
Hi Friends how can i send Email with files attached in asp.net by opening a file dialog when ADD button is clicked Thanks in advance
Hi This is the code in ASP.Net to send email with attachments Dim mailMessage As New MailMessage() 'creating an instance of the MailMessage class mailMessage.From = "xyz@mydomain.com" 'senders email address mailMessage.To = "xyz@abc.com;san@universe.com;sen@baw.com" 'multiple recipient's mailMessage.Cc = "carboncopy@sendersemail.com" 'email address of the Cc recipient mailMessage.Bcc = "blindcarboncopy@sendersemail.com" 'email address of the Bcc recipient mailMessage.Subject = "Hello" 'subject of the email message mailMessage.BodyFormat = MailFormat.HTML 'HTML message format mailMessage.Body = "" & "This tutorial is sending an HTML email_ with an ASP.NET app." & "" 'message body, html message Dim Attach As MailAttachment = New MailAttachment("C:\images\sun.gif") mailMessage.Attachments.Add(Attach) 'adding an attachment mailMessage.Priority = MailPriority.Normal 'email priority. Can be low, normal or high SmtpMail.SmtpServer = "mail.yourserver.com" 'mail server used to send this email. modify this line based on your mail server SmtpMail.Send(mailMessage)
-
Hi This is the code in ASP.Net to send email with attachments Dim mailMessage As New MailMessage() 'creating an instance of the MailMessage class mailMessage.From = "xyz@mydomain.com" 'senders email address mailMessage.To = "xyz@abc.com;san@universe.com;sen@baw.com" 'multiple recipient's mailMessage.Cc = "carboncopy@sendersemail.com" 'email address of the Cc recipient mailMessage.Bcc = "blindcarboncopy@sendersemail.com" 'email address of the Bcc recipient mailMessage.Subject = "Hello" 'subject of the email message mailMessage.BodyFormat = MailFormat.HTML 'HTML message format mailMessage.Body = "" & "This tutorial is sending an HTML email_ with an ASP.NET app." & "" 'message body, html message Dim Attach As MailAttachment = New MailAttachment("C:\images\sun.gif") mailMessage.Attachments.Add(Attach) 'adding an attachment mailMessage.Priority = MailPriority.Normal 'email priority. Can be low, normal or high SmtpMail.SmtpServer = "mail.yourserver.com" 'mail server used to send this email. modify this line based on your mail server SmtpMail.Send(mailMessage)
-
Hi The code u sent works fine for single file but what if i want to send multiple file Thanks in Advance
-
You add
Dim Attach As MailAttachment = New MailAttachment("C:\images\sun.gif") mailMessage.Attachments.Add(Attach)
as how many times you want to get for multiple files attachment