E-Mail Problem

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/13/2012 3:30:42 PM
Gravatar
Total Posts 148

E-Mail Problem

Hi:

 

I am trying to send an e-mail from my application.  I transferred these settings:

<add key="SMTPServer" value="myexchg"/>
  <add key="SMTPRequiresAuthentication" value="false"/>
  <add key="SMTPUseSsl" value="false"/>
  <add key="SMTPPort" value="25"/>
  <add key="SMTPUser" value="user@myDomainName.net"/>
  <add key="SMTPPassword" value="mypassword"/>
  <add key="SMTPTimeoutInMilliseconds" value="30000"/>

to my User.config file.

 

​I am receiving an error of "host not specified".  

6/13/2012 4:11:59 PM
Gravatar
Total Posts 18439

Re: E-Mail Problem

What does the code you use to send the email look like?

6/13/2012 5:06:56 PM
Gravatar
Total Posts 148

Re: E-Mail Problem

           MailMessage message = new MailMessage();
            message.From = new MailAddress("sender@mydomain.net");

            message.To.Add(new MailAddress("myname@mydomain.net"));

            message.IsBodyHtml = true;

            message.Subject = "<b>This is the subject</b>";
            message.Body = "<b>This is the content</b>";

            SmtpClient client = new SmtpClient();
           
            client.Host = "myhost";

            try
            {
                client.Send(message);
            }
            catch (SmtpException smtpEx)
            {

                string s = smtpEx.Message;

            }
            catch (Exception ex)
            {
                string s = ex.Message;

            }

 

It works but I need to set the "host" in code.

6/14/2012 6:40:45 AM
Gravatar
Total Posts 18439

Re: E-Mail Problem

Hi,

The problem is that there is nothing to automagically assign those config settings to the SmtpClient object. I've just created an article Sending Email From Custom Code, to illustrate our helper methods that you can use to send email.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.