01.
Public
Sub
SendMailOneAttachment(
ByVal
From
As
String
, _
02.
ByVal
sendTo
As
String
,
ByVal
Subject
As
String
, _
03.
ByVal
Body
As
String
, _
04.
Optional
ByVal
AttachmentFile
As
String
=
""
, _
05.
Optional
ByVal
CC
As
String
=
""
, _
06.
Optional
ByVal
BCC
As
String
=
""
, _
07.
Optional
ByVal
SMTPServer
As
String
=
""
)
08.
09.
Dim
myMessage
As
MailMessage
10.
11.
Try
12.
myMessage =
New
MailMessage()
13.
With
myMessage
14.
.
To
= sendTo
15.
.From = From
16.
.Subject = Subject
17.
.Body = Body
18.
.BodyFormat = MailFormat.Text
19.
20.
21.
If
CC <>
""
Then
.Cc = CC
22.
If
BCC <>
""
Then
.Bcc =
""
23.
24.
If
FileExists(AttachmentFile)
Then
_
25.
.Attachments.Add(AttachmentFile)
26.
27.
End
With
28.
29.
If
SMTPServer <>
""
Then
_
30.
SmtpMail.SmtpServer = SMTPServer
31.
SmtpMail.Send(myMessage)
32.
33.
Catch
myexp
As
Exception
34.
Throw
myexp
35.
End
Try
36.
37.
End
Sub