- public void sendEmail()
- {
- String userName = "[email protected]";
- String password = "password for from address";
- MailMessage msg = new MailMessage("[email protected] ", " [email protected] ");
- msg.Subject = "Your Subject Name";
- StringBuilder sb = new StringBuilder();
- sb.AppendLine("Name: " + txtname.Text);
- sb.AppendLine("Mobile Number: " + txtmbno.Text);
- sb.AppendLine("Email:" + txtemail.Text);
- sb.AppendLine("Drop Downlist Name:" + ddllinksource.SelectedValue.ToString());
- msg.Body = sb.ToString();
- Attachment attach = new Attachment(Server.MapPath("folder/" + ImgName));
- msg.Attachments.Add(attach);
- SmtpClient SmtpClient = new SmtpClient();
- SmtpClient.Credentials = new System.Net.NetworkCredential(userName, password);
- SmtpClient.Host = "smtp.office365.com";
- SmtpClient.Port = 587;
- SmtpClient.EnableSsl = true;
- SmtpClient.Send(objMailMessage);
- }
Sending multiple field values of registration page and also an attachment to the particular mail by using office 365 with C#.net code.
