Re: Sending email from within app
- From: cj <cj@xxxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 10:52:45 -0400
Here's a simple way
Public Sub StartMail(ByVal [To] As String, Optional ByVal subj As String = "", Optional ByVal Body As String = "")
Try
Dim mailProcess As New ProcessStartInfo
mailProcess.UseShellExecute = True
mailProcess.FileName = "mailto:" & [To] & "?subject=" & subj & "&body=" & Body
Process.Start(mailProcess)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Here's my favorite way but it's 2005 only
Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
msg.From = New System.Net.Mail.MailAddress("me@xxxxxxxx")
msg.To.Add("bob@xxxxxxxx")
msg.Subject = "Test Msg"
msg.Body = "Can you hear me now?"
smtp.Host = "smtp.myco.com"
smtp.Port = 25
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New System.Net.NetworkCredential("me@xxxxxxxx", "mypass")
smtp.Send(msg)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Got one more I'll find later.
John wrote:
Hi.
How does one send email from within a vb.net app?
Thanks
Regards
- Follow-Ups:
- Re: Sending email from within app
- From: cj
- Re: Sending email from within app
- References:
- Sending email from within app
- From: John
- Sending email from within app
- Prev by Date: Re: Sending email from within app
- Next by Date: Re: Finding a share's directory spec
- Previous by thread: Re: Sending email from within app
- Next by thread: Re: Sending email from within app
- Index(es):
Relevant Pages
|