Sending Email


Author
Message
Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I am planning to allow users to send mail messages via my application and was wondering what you use?
Replies
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
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

Keith Chisarik
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search