Solved

Issues Sending Mail Google Apps ASP.Net

Posted on 2009-04-01
2
515 Views
Last Modified: 2013-12-17
Currently I am attempting to send an email using my google apps account which is registered properly for my domain. Upon running the code below I receive the error.

The remote certificate is invalid according to the validation procedure.
MailMessage message = new MailMessage();
            message.To.Add(to);
            message.From = new MailAddress("me@mydomain.com", "myname", System.Text.Encoding.UTF8);
            message.Subject = subject;
            message.SubjectEncoding = System.Text.Encoding.UTF8;
            message.Body = message2;
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.IsBodyHtml = false;
            message.Priority = MailPriority.Normal;
            SmtpClient emailClient = new SmtpClient();
            emailClient.Credentials = new NetworkCredential("me@mydomain.com", "secret");
            emailClient.Port = 587;
            emailClient.Host = "smtp.gmail.com.";
            emailClient.EnableSsl = true;
            emailClient.Send(message);

Open in new window

0
Comment
Question by:greggoodwin2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
KPMT-Technician earned 500 total points
ID: 24042415
I have a few questions:
  Is the machine that is running this web appication have the ablitity to communication with google via port 587?
  Is the machine that is running this web application behind a firewall?
  Line 11 on the above sample code - Are the Network Credential a valid Google email address?

Comment:
  Line 13 on the above sample code - "smtp.gmail.com." remove the last (.) - type-o only, dns will resovle the correct IP Address with or without it.
0
 

Author Closing Comment

by:greggoodwin2
ID: 31565416
Thanks I opened the ports on the web server and removed the (.) now it all runs well!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question