Is this possible? I was able to do this with my self with this code:
string fromaddr = "olivearlerel@gmail.com";
string toaddr = "olivearlerel@gmail.com";//TO ADDRESS HERE
string password = "password";
MailMessage msg = new MailMessage();
msg.Subject = "Hope you got this!";
msg.From = new MailAddress(fromaddr);
string externalip = new WebClient().DownloadString("icanhazip.com");
msg.Body = externalip;
msg.To.Add(new MailAddress(toaddr));
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
NetworkCredential nc = new NetworkCredential(fromaddr, password);
smtp.Credentials = nc;
smtp.Send(msg);
However, when my Skype friend runs this program (So that the program sends me his IP address through email), he gets an exception and I have a feeling its because he can't access my email to send it to me.
Is there any settings I need to change in my gmail account so that the program he runs can log into it? Or is there a different method for this? This would help greatly, thanks!
Exception he had:
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. u21sm2465240pfg.121 - gsmtp