How to send mail to another email id with attachment file

C# Code:

Attachment at = new Attachment(Server.MapPath(MemberPic)); //for attached file.... 'MemberPic' is file path , is string format…
                    MailMessage Msg = new MailMessage();
                    string FromMail = "";
                    string Password = "XXXXXX"// "XXXXXX" is sender password…
                    Msg.From = new MailAddress(FromMail);
                    // Recipient e-mail address..
                    string ToMail = "";   //Receiver email id…
                    string MsgBody = "Thank you…, Softtechsolving.. plz find attached file..";
                    AlternateView htmlMsgView = AlternateView.CreateAlternateViewFromString(MsgBody, null, MediaTypeNames.Text.Html);
                    Msg.Subject = "Soft-Tech Solving;
                    Msg.Body = MsgBody;

                    //send the message
                    SmtpClient smtp = new SmtpClient("");

                    //to authenticate we set the username and password properites on the SmtpClient
                    smtp.Credentials = new NetworkCredential(FromMail, Password);

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Net.Mail;

using System.Net.Mime;

Popular posts from this blog

mvc jquery save

jquery save & fetch