Amazon Ad

Friday 28 November 2014

Send Email To Any Email From Any Email

Hi Guys,

Following is the code for sending email to any user from any user. The below code is a good code and please do not misuse this.      

 MailMessage objMail = new MailMessage();
    //Replace email_of_the_user with the email whom you want to send to
            objMail.To.Add("email_of_the_user");
    //Replace email_to_be_cc'ed with the email whom you want to cc to
            objMail.CC.Add("email_to_be_cc'ed");
    //Replace Your_Email_ID with email id from whom you want the email to be sent from
            objMail.From = new MailAddress("Your_Email_ID", "Alias Name");

    //Subject of the email
            objMail.Subject = "Subject for the email";

            StringBuilder emailbody = new StringBuilder();
            emailbody.Append("Dear User,<br/><br/>");
            emailbody.Append("This is a test email <br/>");
            emailbody.Append("<br/><br/>Thanks<br/><b>Division of Infotech</b>");
            objMail.Body = emailbody.ToString();
            objMail.Priority = MailPriority.High;
            objMail.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.Timeout = 600000;
        //Replace EmailID with Email Id from where you want the email to be sent to
        //Replace Password with the email(email from) password
            smtp.Credentials = new System.Net.NetworkCredential("EmailID", "Password");
            smtp.EnableSsl = true;
            smtp.Send(objMail);
            objMail.Dispose();

Thanks
Ritesh

No comments:

Post a Comment

Comments are welcome, Please join me on my Linked In account

http://in.linkedin.com/pub/ritesh-tandon/21/644/33b

How to implement Captcha v3 in ASP.NET

 I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...