'Library CDO
'D:\WINDOWS\system32\cdosys.dll
'Microsoft CDO for Windows 2000 Library
Const cdoBasic = 1 'basic (clear-text) authentication
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Phung Van Huy"" <codjng@gmail.com>"
objMessage.To = "huyphungvan@yahoo.com"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."
'This section provides the configuration information for the remote SMTP server.
With objMessage.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "huyphungvan"
'Your password on the SMTP server
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "***********"
'Server port (typically 25)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
'Get error: Must issue a STARTTLS command first, if server use SSL but you set False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
'End remote SMTP server configuration section
On Error Resume Next
objMessage.Send
If Err <> 0 Then
Msgbox "Send email failed: " & Err.Description
Else
Msgbox "OK!"
End if
Title:
Send email with Gmail account via vbscript
Description:
'Library CDO 'D:\WINDOWS\system32\cdosys.dll 'Microsoft CDO for Windows 2000 Library Const cdoBasic = 1 'basic (clear-text) ...
...
Rating:
4