none
System.Net.Mail SMTP/IIS security RRS feed

  • Question

  • I work in a manufacturing environment so most of my scripting experience is in proprietary languages. However, the software that I'm currently using (Archestra System Platform) allows for .NET scripting.

    I need to send event base e-mail so it looked like System.Net.Mail could be used. 

    I set upSmtpClient.Host, .Port and .EnableSSL = true.  I made registry edits to EnableSSL per other stuff that I googled.

    This on a W2008R2 server in a development environment.  I'm using smtp.gmail.com, port 465 (which I can ping from the hosting server)

    But I don't understand how/where to enter my gmail account credentials?

    I had enabled and configured IIS on the server.  And saw that I could put my gmail credentials in there but that didn't seem to work either.

    The error that I'm getting says "failure sending mail".  Everything that I read about that error indicated that it was something with the connection to the SMTP server.

    This is not my regular programming environment so I'm hoping it's something simple that I just am clueless about.

    'Declare local variables
    Dim objSMTPClient as System.Net.Mail.SmtpClient;
    Dim objMessage as System.Net.Mail.MailMessage;
    Dim strFrom as String;
    Dim strRecipients as String;
    Dim strSubject as string;
    Dim strBody as string;
    
    'Set up basic SMTP configuration
    objSMTPClient = New System.Net.Mail.SmtpClient;
    objSMTPClient.Host = "smtp.gmail.com";
    objSMTPClient.Port = 465;
    objSMTPClient.UseDefaultCredentials = true;
    objSMTPClient.EnableSsl = true;
    
    'Set the to & from
    strFrom = me.Mail.From;
    strRecipients = me.Mail.Recipients;
    objMessage = New System.Net.Mail.MailMessage (strFrom,strRecipients);
    
    'Build up a subject line
    strSubject = me.Mail.Subject + ">> "+ Now() + " <<" + Me.Area;
    objMessage.Subject = strSubject;
    
    'Fill out the body of the email
    strBody = me.Mail.Body + objSMTPClient.Host + " " + objSMTPClient.Port;
    objMessage.Body = strBody;
    objMessage.IsBodyHTML = False;
    
    if me.Mail.Debug then
    	LogMessage("SMTP server & port: " + objSMTPClient.Host + " " + objSMTPClient.Port.ToString());
    	LogMessage("To: " + strFrom + " - Recipients: " + strRecipients);
    	LogMessage("Subject : " + strSubject);
    	LogMessage("Body : " + strBody);
    endif;
    
    'Send the finished message
    objSMTPClient.Send(objMessage);

    Tuesday, August 15, 2017 6:51 PM

Answers

  • I had already been to that web site.

    Let me ask perhaps some more basic questions"

    If I'm using the .net.mail.send, do I have to have IIS installed on the server that is running the code?

    In IIS 7.0 there is a configuration for SMTP E-Mail.  When the code sets up .Net.Mail.SMTPclient attributes, is it re-configuring IIS or doing something else?

    • Marked as answer by Kirkee Tuesday, August 22, 2017 5:20 PM
    Wednesday, August 16, 2017 1:27 PM

All replies

  • Kirkee,

    I visited the Archestra website. I saw the where using parts of .Net likewise Windows Forms controls. 

    However the scritpting language they use is not VB. I don't know it, maybe it is home brewed therefore I think you better can contact them. 

    http://blog.wonderware.com/2016/01/dot-net-controls-importing-and-managing.html


    Success
    Cor

    Tuesday, August 15, 2017 8:09 PM
  • I know it's not VB but people told me to post here b/c my issue is with the .Net system.net.mail

    I'm getting the explicit message "failure to send" when using .Send

    I'm trying to understand how to configure the security either in IIS or with this class so that the send will work.

    The Archestra people told me it's a Windows issue b/c the .Net is giving me the error

    Tuesday, August 15, 2017 8:28 PM
  • I know it's not VB but people told me to post here b/c my issue is with the .Net system.net.mail

    I'm getting the explicit message "failure to send" when using .Send

    I'm trying to understand how to configure the security either in IIS or with this class so that the send will work.

    The Archestra people told me it's a Windows issue b/c the .Net is giving me the error

    Yea likewise somebody in North Korea tells the problem is in the USA

    Your code does absolutly not look like VB so the error can be everywhere.

    However, look at this everything you wanted to know about SMTP website

    http://systemnetmail.com/


    Success
    Cor

    Tuesday, August 15, 2017 8:50 PM
  • I had already been to that web site.

    Let me ask perhaps some more basic questions"

    If I'm using the .net.mail.send, do I have to have IIS installed on the server that is running the code?

    In IIS 7.0 there is a configuration for SMTP E-Mail.  When the code sets up .Net.Mail.SMTPclient attributes, is it re-configuring IIS or doing something else?

    • Marked as answer by Kirkee Tuesday, August 22, 2017 5:20 PM
    Wednesday, August 16, 2017 1:27 PM