Please refer the following Visual Basic 6 example codes to write your actual codes.
Private Sub usSendMail()
'' Declare and instance objects.
Dim smt As New SMTP
Dim msg As New Message
''
'' Set SMTP object.
smt.SMTPUser = "nosalee@trisunsoft.com"
smt.SMTPPasswd = "PutItHere"
smt.ProxyHost = "TestProxyServer"
smt.Connect "mail.tssi.com", 25
''
'' Connect to the SMTP server.
If smt.State <> tscConnected Then
MsgBox "Connecting to the SMTP server unsuccessfully!", vbExclamation
GoTo Ext
End If
''
'' Designate the sender.
msg.Sender.DispName = "TSC Tester"
msg.Sender.EmailAddr = "NosaLee@TriSunSoft.com"
''
'' Designate the 'To' recipients.
msg.Receivers.Add
msg.Receivers.Item(msg.Receivers.Count).DispName = "TSSI Sales"
msg.Receivers.Item(msg.Receivers.Count).EmailAddr = "Sales@TriSunSoft.com"
''
'' Designate the 'CC' recipients.
msg.CC.Add
msg.CC.Item(msg.CC.Count).DispName = "TSSI Support"
msg.CC.Item(msg.CC.Count).EmailAddr = "Support@TriSunSoft.com"
''
'' Designate the 'BCC' recipients.
msg.BCC.Add
msg.BCC.Item(msg.BCC.Count).DispName = "Nosa Lee"
msg.BCC.Item(msg.BCC.Count).EmailAddr = "NosaLee@TriSunSoft.com"
''
'' Set other property for Message object.
msg.Subject = "The test message for TSC!"
msg.Content = "The test content for TSC!"
msg.Charset = "utf-16"
msg.Attachs.Add
msg.Attachs(msg.Attachs.Count).FileName = "test.txt"
msg.Attachs(msg.Attachs.Count).FullName = "c:\test.txt"
''
'' Send email.
If smt.SendMsg(msg) Then
MsgBox "Sent successfully!", vbInformation
Else
MsgBox "Sent unsuccessfully!", vbExclamation
End If
''
'' Disconnect from the SMTP server.
smt.Disconnect
''
'' Destroy objects.
Ext:
Set smt = Nothing
Set msg = Nothing
''
End Sub
|