HTML E-Mail Message with Attachment via GMail servers using SMTP authentication and SSL

Author Message
Hackoo

  • Total Posts : 104
  • Scores: 4
  • Reward points : 0
  • Joined: 6/25/2010
  • Status: offline
HTML E-Mail Message with Attachment via GMail servers using SMTP authentication and SSL Tuesday, February 01, 2011 12:18 PM (permalink)
0
This sample sends a simple HTML E-Mail Message with Attachment File via GMail servers using SMTP authentication and SSL.
It's like any other mail but requires that you set the SMTP Port to 465 and tell CDO to use SSL. 
Please i'm waiting for your feedbacks and yours tries. And tell me if this script works with you or not ?
With my Best Regards !
 'This sample sends a simple HTML EMail Message with Attachment File via GMail servers using SMTP authentication and SSL.'It's like any other mail but requires that you set the SMTP Port to 465 and tell CDO to use SSL'By Hackoo © 2011 On Error Resume Next Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). Const cdoAnonymous = 0 'Do not authenticate Const cdoBasic = 1 'basic (clear-text) authentication Const cdoNTLM = 2 'NTLM sFilePath="C:\SSLGmail.rar" 'Path of the Attach File Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "Example CDO Message" objMessage.From = """Me"" <Mymail@gmail.com>" 'change thisobjMessage.To = "dest@yahoo.fr" 'change this ToobjMessage.CC = "dest2@yahoo.fr" 'change this CC means : Carbon Copy objMessage.BCC = "dest3@gmail.com" 'change this BCC means : Blink Carbon Copy sBody = "<center><font size=4 FACE=Tahoma Color=red>This is some sample message in HTML.<br> It was sent using SMTP authentication and SSL." objMessage.HTMLBody = sBody  & _ "<center><font size=4 FACE=Tahoma Color=red>" & _ messageHTML & _ "<br><br><img src=http://photomaniak.com/upload/out.php/i1102064_IDNlogo.gif>" objMessage.AddAttachment sFilePath '==This section provides the configuration information for the remote SMTP server. objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
 'Name or IP of Remote SMTP Server objMessage.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'SMTP SERVER of GMAIL must be inchanged 'Type of authentication, NONE, Basic (Base64 encoded),NTLM objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic 'Your UserID on the SMTP server objMessage.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourLoginGmail@gmail.com" 'change this in yours 'Your password on the SMTP server objMessage.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPasswordGmail" 'change this in yours 'Server port (typically 25 and 465 in SSL mode for Gmail) objMessage.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'don't change this 'Use SSL for the connection (False or True) objMessage.Configuration.Fields.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) objMessage.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMessage.Configuration.Fields.Update 
 '==End remote SMTP server configuration section== 
 objMessage.Send 
 If Err.Number <>0 Then MsgBox Err.Description,16,"Erreur" msgbox "le mail n'a pas pu être envoyé !",16,"Information" Else		msgbox "Le mail a été bien envoyé !",64,"Information" End If On Error GoTo 0 

This Code can be Downloaded here
<message edited by Hackoo on Tuesday, February 01, 2011 5:55 PM>
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9