StrataFrame Forum

Sending Email

http://forum.strataframe.net/Topic11557.aspx

By Michael Reese - 9/18/2007

I am planning to allow users to send mail messages via my application and was wondering what you use?
By Greg McGuffey - 9/18/2007

.NET has classes to do this internally. See the System.Net.Mail namespace and this article



http://www.systemnetmail.com/default.aspx



This works fine if your users are on your network and they will use your smtp server to do the sending. However, in my case, many of my users are remote and the only way is to configure the system to use THEIR smtp servers (whaterver that might be).


By Keith Chisarik - 9/19/2007

something like this perhaps



Dim mail As New MailMessage()

Dim smtp As New SmtpClient(Me.txtSMTPServer.Text)



' form the email, catch errors and report

Try

mail.IsBodyHtml = True



'set the addresses

mail.From = New MailAddress("SDSILogtool@sigmadatainc.com", "SDSI Logtool Utility")

mail.To.Add(Me.txtEmailAddress.Text)



'set the content

mail.Subject = "Backup Report - " & Me.txtCompanyName.Text & " " & Me.txtCurrentLogDate.Text

mail.Body = emailbody



'to authenticate we set the username and password properites on the SmtpClient

smtp.Credentials = New Net.NetworkCredential(Me.txtSMTPUsername.Text, Me.txtSMPTPassword.Text)

Catch ex As System.Exception

MsgBox("Error forming email. " & ex.Message.ToString)

End Try



'send, catch errors and report

Try

smtp.Send(mail)

Catch ex As System.Exception

MsgBox("Error sending email, check SMTP settings, or contact your administrator." & ex.Message.ToString)

End Try
By StrataFrame Team - 9/19/2007

Good job, guys.  Don't forget that you can also make the body of an email HTML by setting the IsBodyHtml property after you set the Body property on the message.  It allows you to include formatting and such.
By Michael Reese - 9/19/2007

Ok thanks,

I was looking at the Email Factory for .Net which is about $299

By StrataFrame Team - 9/19/2007

Nah, for just email, you can use the .NET classes.  However, I think that email factory was designed for .NET 1.0/1.1, which I don't think had near as many things in the System.Net namespace.  The mail implementation is much more robust in .NET 2.0.

But, there is certainly a market for networking related .NET tools.  You might also try http://www.nsoftware.com/.  They have the IPWorks suite, which contains lots of stuff for HTTP servers, socket communications, and tons of other stuff.