Here's the other. I haven't used it in 2005 yet but in 2003 I did. I
used it to give a user of an app the option to send the contents of say
a text box to someone. It brings up their default mail and puts the
contents and subject in but leaves who they're sending it to blank and
allows them to edit the message etc and send it themselves.
My 2005 example in the previous email is used by some of my programs to
wake us up in the middle of the night with an email to our cell phones
because something happened it didn't like. :( In other words it is a
totally automatic generate and send of a message.
I don't quite remember how the sendto: works any more--it didn't do what
I wanted.
There are other ways to do this but these are all the examples I have.
Private Sub SndMAPIMail(ByV al subj As String, ByVal msg As String)
Try
Dim myMAPISession As New MSMAPI.MAPISess ion
Dim myMAPIMessage As New MSMAPI.MAPIMess ages
myMAPISession.D ownLoadMail = False
myMAPISession.S ignOn()
myMAPISession.N ewSession = True
myMAPIMessage.S essionID = myMAPISession.S essionID
myMAPIMessage.C ompose()
myMAPIMessage.M sgSubject = subj
myMAPIMessage.M sgNoteText = msg
Try
myMAPIMessage.S end(True)
Catch ex As Exception
If Not ex.Message = "User cancelled process" Then
MessageBox.Show (ex.Message)
End If
End Try
myMAPISession.S ignOff()
myMAPISession.N ewSession = False
Catch
End Try
End Sub
cj wrote:
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 ProcessStartInf o
mailProcess.Use ShellExecute = True
mailProcess.Fil eName = "mailto:" & [To] & "?subject=" & subj
& "&body=" & Body
Process.Start(m ailProcess)
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("m e@myco.com")
msg.To.Add("bo* @ACME.com")
msg.Subject = "Test Msg"
msg.Body = "Can you hear me now?"
smtp.Host = "smtp.myco. com"
smtp.Port = 25
smtp.DeliveryMe thod = Net.Mail.SmtpDe liveryMethod.Ne twork
smtp.Credential s = New
System.Net.Netw orkCredential(" me@myco.com", "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