2016年1月8日 星期五

VBA Email via Gmail CDO Method - Microsoft Access Programmers

Sub SendMailFromGmail() Dim iMsg As Object Dim iConf As Object Dim Flds As Variant Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "test@gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "test132" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'smtp mail server .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'stmp server .Update End With With iMsg Set .Configuration = iConf .To = "test@gmail.com" .From = "test@gmail.com" .Subject = "Hello" & Time .TextBody = "Hi Dude" .Send End With Set iMsg = Nothing Set iConf = Nothing End Sub

沒有留言 :

張貼留言