< FACE="arial,verdana,helvetica"> MarshallSoft

Visual Basic Email Example


' connect to SMTP server then send email

Function SendMail(ByVal ToList As String, ByVal Subject As String, ByVal Message As String) As Integer
Dim Code As Integer
Dim SmtpHost As String
Dim SmtpUser As String
Dim SmtpPass As String
Dim SmtpFrom As String
Dim SmtpReply As String
Dim ccList As String
Dim bccList As String
Dim Attachments As String
' specify the server, user name, and password
SmtpHost = "smtp.my-isp.com"
SmtpUser = "my-user-name"
SmtpPass = "my-password"
char *SmtpFrom = "<mike@my-isp.com>"
char *SmtpReply= "<mike@my-isp.com>"
' specify CC list, BCC list, and attachment filenames
ccList = Char(0)
bccList = Chr(0)
Attachments = Chr(0)
' specify the port to connect on (default port is 25)
Code = seeIntegerParam(0, SEE_SMTP_PORT, 587)
' specify the user name and password for SMTP authentication
seeStringParam(0, SEE_SET_USER, SmtpUser)
seeStringParam(0, SEE_SET_SECRET, SmtpPass)
' connect to SMTP server
Code = seeSmtpConnect(0, SmtpHost, SmtpFrom, SmtpReply)
' error ? (negative return codes are errors)
If Code < 0 Then
  SendMail = Code
  Exit Function
Else
  ' send email to list of recipients (ToList)
  SendMail = seeSendEmail(0,ToList,ccList,bccList,Subject,Message,Attachments)
End If
End Function

MSC Logo

HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.