Public Sub SendMailOneAttachment(ByVal From As String, _
ByVal sendTo As String, ByVal Subject As String, _
ByVal Body As String, _
Optional ByVal AttachmentFile As String = "", _
Optional ByVal CC As String = "", _
Optional ByVal BCC As String = "", _
Optional ByVal SMTPServer As String = "")
Dim myMessage As MailMessage
Try
myMessage = New MailMessage()
With myMessage
.To = sendTo
.From = From
.Subject = Subject
.Body = Body
.BodyFormat = MailFormat.Text
'CAN USER MAILFORMAT.HTML if you prefer
If CC <> "" Then .Cc = CC
If BCC <> "" Then .Bcc = ""
If FileExists(AttachmentFile) Then _
.Attachments.Add(AttachmentFile)
End With
If SMTPServer <> "" Then _
SmtpMail.SmtpServer = SMTPServer
SmtpMail.Send(myMessage)
Catch myexp As Exception
Throw myexp
End Try
End Sub