Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
MailMessage mailMSG = new MailMessage();
        SmtpClient myMail = new SmtpClient();
        mailMSG.To.Add(new MailAddress(txtTo.Text));
        mailMSG.From = new MailAddress(txtFrom.Text);
        mailMSG.Subject = txtSubject.Text;
        mailMSG.Body = txtContent.Value;
        mailMSG.BodyEncoding = System.Text.Encoding.ASCII;
        mailMSG.IsBodyHtml = true;
        mailMSG.Priority = MailPriority.Normal;      
        myMail.UseDefaultCredentials = true;
        myMail.Host = "127.0.0.1";     
        myMail.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
        myMail.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
        myMail.Send(mailMSG);


I have problem to send mail with this at remote server http://xyx.in
how to send please reply me.........please
Thanks.
Posted
Updated 4-May-12 0:39am
v2
Comments
Karthik Harve 4-May-12 6:40am    
[Edit] pre tags added
jim lahey 4-May-12 6:41am    
is there an error message?
Sangramsingh Pawar 4-May-12 6:49am    
state your problem, I can't get any idea from your question

1 solution

C#
MailMessage mailMSG = new MailMessage();

SmtpClient myMail = new SmtpClient(yourSMTPhostaddress, your SMTP Port);

mailMSG.To.Add(new MailAddress(txtTo.Text));
mailMSG.From = new MailAddress(txtFrom.Text);
mailMSG.Subject = txtSubject.Text;
mailMSG.Body = txtContent.Value;
mailMSG.BodyEncoding = System.Text.Encoding.ASCII;
mailMSG.IsBodyHtml = true;
mailMSG.Priority = MailPriority.Normal; 

myMail.Credentials =  new NetworkCredential(specify MailUserName,specify MailPassword);

//if the SMTP server is SSL enabled(https)then set the Enable SSL property to //true otherwise set false
myMail.EnableSsl = true; 

myMail.Send(mailMSG);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900