
launch default email client with a new message
says...
Quote:
> Anyone have a code example of how to launch the systems default email client
> with a new message while setting the to, subject, and message body?
behind a button for example:
1)
sendmail.Send( _
"The subject", _
"The Body", _
"Optional smtpserver else localserver will be used", _
"Optional CC", _
"Optional BCC", _
"Optional c:\temp\Attachment", _
"Optional Priority normal,low,high", _
Optional Post in HTML? 1 or 0)
2)
reference your project to the system.web
3)
create a module with:
Imports System.Web.Mail
Module sendmail
Function Send(ByVal strFROM As String, ByVal strTO As String, ByVal
strSUBJECT As String, ByVal strBODY As String, Optional ByVal
strSMTPSERVER As String = "localhost", Optional ByVal strCC As
String = "", Optional ByVal strBCC As String = "", Optional ByVal
strATTACHMENT As String = "", Optional ByVal strPRIORITY As String
= "Normal", Optional ByVal strHTMLPOST As Boolean = False)
Dim email As New MailMessage()
Dim smtpserver As SmtpMail
'REQUIERD ITEMS FOR SENDING
email.From = strFROM 'From Address
email.To = strTO 'To Address
email.Subject = strSUBJECT 'Subject
email.Body = strBODY 'Body text as string
'Optional ITEMS FOR SENDING
smtpserver.SmtpServer = strSMTPSERVER 'This is your mail server
email.Cc = strCC 'Send a Carbon-Copy (OPTIONAL)
email.Bcc = strBCC 'Send a Blind Carbon-Copy (OPTIONAL)
'email-attachment
If strATTACHMENT <> "" Then
Try
email.Attachments.Add(New System.Web.Mail.MailAttachment _
(strATTACHMENT))
Catch x As Exception
MsgBox(x.Message.ToString) 'Return the error to the user
End Try
End If
'mail priority
Select Case UCase(strPRIORITY)
Case "LOW"
email.Priority = MailPriority.Low
Case "NORMAL"
email.Priority = MailPriority.Normal
Case "HIGH"
email.Priority = MailPriority.High
Case Else
email.Priority = MailPriority.Normal
End Select
'Post as type:
If (strHTMLPOST) Then
email.BodyFormat = MailFormat.Html
Else
email.BodyFormat = MailFormat.Text
End If
MsgBox("sending:" & _
email.From & Chr(13) & _
email.To & Chr(13) & _
email.Subject & Chr(13) & _
email.Body & Chr(13) & _
email.Priority & Chr(13) & _
smtpserver.SmtpServer)
'Sending the mail
Try
smtpserver.Send(email)
Catch x As Exception
MsgBox(x.Message.ToString) 'Return the error to the user
End Try
'clearing all
email = Nothing
smtpserver = Nothing
End Function
End Module
regards git