locked
send and email from domainContext.cs RRS feed

  • Question

  • Hi there,  below is some code which appears to work.  I am using IIS as the server for this .Web project in VWD.  the client credentials seem correct when I look at them in debug mode.  The mail message also seems valid.  The code does not throw an error (there are some catch {} clauses below it which do not fire).  Only problem is that no email message is ever received.  What am I doing wrong?  Or how do I find out what is wrong?

                 MailMessage message = new MailMessage(from, toAddress);
                   message.Subject = returnTheMessageSubject(buyPicks, sellPicks, flushWithFunds);
                   message.Body = "Your Portfolio currently has a performance of " + p.IRR.ToString() + "%";
                   message.IsBodyHtml = false;
                   try
                   {
                       SmtpClient client = new SmtpClient("localhost");
                       client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
                       client.Send(message);
                   }

    Also I tried adding this to webconfig.  I found it in a search of the silverlight.net forum, and it seeemed sensible.  The result is the same, with or without it.

       <system.net>
            <mailSettings>
                <smtp>
                    <network host="localhost" userName="xxxxxx-j-xxxx@hotmail.com" password="xxxxxxxxxxx" port="25" />
                </smtp>
            </mailSettings>
        </system.net>
    

    Any suggestions gratefully received.


    Tuesday, October 23, 2012 12:29 AM

Answers

  • This is how you do it for Windows Live Mail SMTP Server.  I think that the issue was the port number.

                       /// this is the development configuration.  Live will be a different one.
                       SmtpClient client = new SmtpClient("smtp.live.com");
                       client.EnableSsl = true;
                       NetworkCredential credentials = new System.Net.NetworkCredential();
                       credentials.UserName = "michael-j-ryan@hotmail.com";
                       credentials.Password = "xxxxxxxxxxx";
                       client.UseDefaultCredentials = true;
                       client.Credentials = credentials;
                       client.Port = 587;
                       client.Send(message);


    Thanks for the suggestions,

    Tuesday, October 23, 2012 11:28 PM

All replies

  • http://social.msdn.microsoft.com/Forums/en-US/silverlightarchieve/thread/6efcc6dd-5bce-40d8-a15b-ca95ea0aee8b//1

    http://social.msdn.microsoft.com/Forums/en-US/silverlightgen/thread/19a1cec2-ea6b-4479-81ba-4496adac6841//1

    http://www.codeproject.com/Tips/353086/Sent-Email-Yahoo-SMTP-with-Silverlight-5-WCF-RIA

    Tuesday, October 23, 2012 2:53 AM
  • This is how you do it for Windows Live Mail SMTP Server.  I think that the issue was the port number.

                       /// this is the development configuration.  Live will be a different one.
                       SmtpClient client = new SmtpClient("smtp.live.com");
                       client.EnableSsl = true;
                       NetworkCredential credentials = new System.Net.NetworkCredential();
                       credentials.UserName = "michael-j-ryan@hotmail.com";
                       credentials.Password = "xxxxxxxxxxx";
                       client.UseDefaultCredentials = true;
                       client.Credentials = credentials;
                       client.Port = 587;
                       client.Send(message);


    Thanks for the suggestions,

    Tuesday, October 23, 2012 11:28 PM