Send Email

Hi,

I am not able to send email with the send email action. I tried to do a little application in c# and it's working fine.

Here is the code :

 

    MailMessage msg = new MailMessage();
    msg.From = "email1@wonderware.com";
    msg.To = "eamil1@wonderware.com";
    msg.Subject = "tes";
    msg.Body = "klklk";
    msg.BodyFormat = MailFormat.Text; // can be MailFormat.HTML

    /* you can ignore following line for encoding, .NET will use your PC default text encoding */
    //msg.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-2");

    /* if you need attachment */
    MailAttachment ma = new System.Web.Mail.MailAttachment("c:\\doc\\test.txt");
    msg.Attachments.Add(ma);
    /* end attachment* section */
    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "2"); //basic authentication
    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "Username");//this.username.Text); //set your username here
    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Password");//this.password.Text); //set your password here


    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
    // - smtp.gmail.com use STARTTLS (some call this SSL)
    //msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");

    SmtpMail.SmtpServer = "SMTP Server"; //assign smtp server here
    SmtpMail.Send(msg); //this line actually fire the msg out

There is something in the configuration the smtp.authenticate that is set to 2.. else it is not working. Should this be the problem that i have?

Thank you,

Alexis

Finally i arrived to make it works. Without authenticate checked it works. Our smtp server needs authentification but i think that without authenticate checked it takes the windows user credential.

But maybe there is something special because in my code example it is working with the same username and password that i was using in the send email action.

It is working, but i want to know why it was'nt before...

thank you

Hi Alexis,

What SMTP server are you using? Could your SMTP server be requiring either SSL-encrypted authentication or no authentication at all?

- Angus

Our smtp server is a microsoft exchange and we must be authenticated to be able to send an email, i don't know if it is using SSL or not.

If you don't know the reason, it doesn't matter, it works but not the way that i was expected.

Thanks you for your time,

Alexis