PowerBASIC Email Example

' connect to SMTP server then send email

Function SendMail(ToList As Asciiz, Subject As Asciiz, Message As Asciiz) As Integer
Dim Code As Integer
Dim SmtpHost As Asciiz
Dim SmtpUser As Asciiz
Dim SmtpPass As Asciiz
Dim SmtpFrom As Asciiz
Dim SmtpReply As Asciiz
Dim ccList As Asciiz
Dim bccList As Asciiz
Dim Attachments As Asciiz
' specify the server, user name, and password
SmtpHost = ""
SmtpUser = "my-user-name"
SmtpPass = "my-password"
SmtpFrom = "<>"
SmtpReply= "<>"
' 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
  ' send email to list of recipients (ToList)
  SendMail = seeSendEmail(0,ToList,ccList,bccList,Subject,Message,Attachments)
End If
End Function

MSC Logo

MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.