Thursday, March 19, 2015

Send Email with only mail host server

Send Email with only mail host server

Guyz..!!!, I wanted to share the mail sending format with only host, it does’t require any from username & password.

I am sharing this to help those who have just mail host server address but not any from credentials to send, follow the steps below, its working & tested .


MailMessage objMailMessage = new MailMessage(
                new MailAddress("AnyDummyMailYouNeedtoShowtoTOUser@Frommail.com", "AnyFromMailNameYoucanWriteHere"),
                new MailAddress(ToWhomeYouWantTosendmail@Tomail.com, "AnyToMailNameYoucanWriteHere")
                );
//ToWhomeYouWantTosentmail@mail.com ==> should be a valid mail address
                objMailMessage.Subject = "Any subject";
                objMailMessage.IsBodyHtml = true
                objMailMessage.CC.Add(youcanAddcchere@ccMail.com);
                string strDesc = "<table><tr><td>Construct Your email template UI here with Message</td></tr></table>" 
                objMailMessage.Body = "<div style='font-family:Trebuchet MS;font-size:13px;font-style:italic;width:650px;'>"+strDesc.ToString()+"</div>";
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "123.124.11.2546";//Your Email Host , this is the example one
                smtp.Send(objMailMessage);  


I hope it’s benefited, feel free to drop your comments below.

No comments: