deostroll
IT diaries...
Sending email in dot net
I guess the classes that deal with smtp all lie in inside the System.Web.Mail namespace. The code snippet below is done in vb.net but you can suitably alter it to the language of your liking. I have just started normal winodows application project, added a few text boxes, labels and two buttons. Before typing out the code you should all the System.Web.MailSystem.Wed.dll reference to your project.



Imports System.Web.Mail



Public Class frmInvMailer

Inherits System.Windows.Forms.Form



#Region " Windows Form Designer generated code "

'Purpose fully omitted

#End Region



Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click

Me.Close()

End Sub



Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click



Dim email As New MailMessage

email.From = txtFrom.Text

email.To = txtTo.Text

email.Subject = txtSub.Text

email.Body = rtxt.Text

SmtpMail.SmtpServer = "172.16.45.21" 'This is the IP of your SMTP server.

SmtpMail.Send(email)

End Sub

End Class















2007-07-24 15:48:42 GMT
Hosted by www.Geocities.ws

1