ASP.NET - Error in sending Email from Google Apps

 
Post new topic   Reply to topic    Aprelium Forum Index -> ASP.NET
View previous topic :: View next topic  
Author Message
Juse1956
-


Joined: 13 May 2015
Posts: 1

PostPosted: Wed May 13, 2015 9:46 am    Post subject: ASP.NET - Error in sending Email from Google Apps Reply with quote

Hello, I want to send Email from my Website hosted at http://hostforlife.eu, and we are using Google Apps for Emails.

Here is my code in ASP.Net/ C#:
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress("utility@mydomain.com", "GotFeedback", System.Text.Encoding.UTF8);
mMailMessage.To.Add(new MailAddress("feedback@mydomain.com"));
mMailMessage.Subject = "subject";
mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mMailMessage.Body = body;
mMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;

SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.UseDefaultCredentials = false;
mSmtpClient.Credentials = new System.Net.NetworkCredential("utility@mydomain.com", "mypassword");
mSmtpClient.Host = "SMTP.GOOGLE.COM";
mSmtpClient.Port = 587;
mSmtpClient.EnableSsl = true;
try
{
mSmtpClient.Send(mMailMessage);
}
catch(Exception e)
{
string edsf = e.ToString();

But I am getting Exception that it is unable to connect to remote server :( Please help. Thanks!
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> ASP.NET All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group