| Author: Anil Kumar Pandey 04 Nov 2008 | Member Level: Diamond | Rating:    Points: 6 |
hi,
u can use the attachment option for sending the mails with the attachments..
please refer the foloowing code for that..
protected void btnSubmit_Click(object sender, EventArgs e) { try { MailAddress SendFrom = new MailAddress(txtFrom.Text); MailAddress SendTo = new MailAddress(txtTo.Text);
MailMessage MyMessage = new MailMessage(SendFrom, SendTo);
MyMessage.Subject = txtSubject.Text; MyMessage.Body = txtBody.Text;
Attachment attachFile = new Attachment(txtAttachmentPath.Text); MyMessage.Attachments.Add(attachFile);
SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text); emailClient.Send(MyMessage);
litStatus.Text = "Message Sent"; } catch (Exception ex) { litStatus.Text=ex.ToString(); } }
Regards Anil Pandey
Thanks & Regards Anil Kumar Pandey
|
| Author: archana 04 Nov 2008 | Member Level: Gold | Rating:   Points: 3 |
Hi Refer to
http://www.systemwebmail.com/
Code for Mailing is as follows
public string SendMailToUser(string MailID, string mailmsg, string mailSubject) { try { SmtpClient smtpAdmin = new SmtpClient(); string ToAddress = MailID; MailMessage MailMessAdmin = new MailMessage("abc@yahoo.com", ToAddress); MailMessAdmin.Subject = mailSubject; MailMessAdmin.Body = mailmsg; smtpAdmin.Send(MailMessAdmin); return ToAddress; } catch (Exception ex) { throw new Exception(ex.Message); } } ---------------------------------------------------------------- In web.config: Under configuration section <system.net> <mailSettings> <smtp>
<network host="127.0.0.1" port="25" userName="abc1@gamil.com" password="abc123"/> </smtp>
</mailSettings> </system.net> ------------------------------------------------------------- Configure SMTP settings
|