Sub sendmail() Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 'Enable SSL Authentication .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Value of 1 enables basic authnetication, '2 enables NTLM Authentication, '0 disables Authentication .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xyz@gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Your Email's Password" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Value of 2 means send using port 'value of 1 means send using a local SMTP server 'value of 3 means send using Exchange Server .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'The SMTP Port which must be enabled in your network by ISP or local Firewall .Update End With With iMsg Set .Configuration = iConf .To = "xyz@gmail.com" .CC = "" .BCC = "" .From = "xyz@gmail.com" .Subject = "Test email sent from QTP Professional" .TextBody = "This is a test email sent using Gmail's SMTP Server with port 25. Blog info is - LearnQTP.info" .AddAttachment "c:\LearnQTP.info.pdf" 'Local path of the file to attached 'For attaching another file, 'repeat the line with new path .Send End With End Sub
Sunday, July 18, 2010
Sending Emails using QTP via Gmail, Hotmail and other Email Service Providers; Using Windows CDO (Collaboration Data Objects)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment