I've never tried MAPI http://www.vb-helper.com/howto_vba_email_mapi.html. This is what I have:
Code:'CDO (Collaboration Data Objects) to send email 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 'CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xx.xxx.x.xx" 'IP address of SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) = 25 .Update End With With iMsg Set .Configuration = iConf .To = "email" .CC = "" .BCC = "" .From = "email" .Subject = "text" .TextBody = "text: " & Now '.AddAttachment .Send End With Set iMsg = Nothing Set iConf = Nothing
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
June, your schemas got truncated when the hyperlink was automatically applied.
Yep, that is annoying. Will fix.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
June,
Running the code below, Access claims the "sendusing" value is invalid.
Not sure what "It's Me"'s reply means, as I don't see any glaring omissions.
Bill
Code:Option Compare Database Option Explicit Private Sub TestImsg() 'CDO (Collaboration Data Objects) to send email 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 'CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "66.249.93.111" 'IP address of SMTP server .Item("http://schemas.microsoft.com/cdo/con...smtpserverport") = 465 .Update End With With iMsg Set .Configuration = iConf .To = "graeaglebill@gmail.com" .CC = "" .BCC = "" .From = "graeaglebill@gmail.com" .Subject = "text" .textBody = "text: " & Now '.AddAttachment .Send End With Set iMsg = Nothing Set iConf = Nothing End Sub
The URLs were contracted by the forum post. Review corrected post.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
OH WOW, am I "out to lunch". Never properly examined the schemas URL's, only looked at what I need to do to provide the I/P address and port for smtp.googlemail.com.
Bill
Trying to run augmented version of June's code. Error is "The transport failed to connect to the server"
I'm not confident that the configurations are correct?
Any ideas?
Bill
Code:Option Compare Database Option Explicit Private Sub TestImsg() 'CDO (Collaboration Data Objects) to send email 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 'CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.googlemail.com" '"66.249.93.111" 'IP address of SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic .Item("http://schemas.microsoft.com/cdo/configuration/smtpsecurity") = "SSL/TLS" .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "graeaglebill@gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "**************" 'My pw at gmail suppressed here .Update End With With iMsg Set .Configuration = iConf .To = "graeaglebill@gmail.com" .CC = "" .BCC = "" .From = "graeaglebill@gmail.com" .Subject = "text" .textBody = "text: " & Now '.AddAttachment .Send End With Set iMsg = Nothing Set iConf = Nothing End Sub
Google Mail, yahoo mail, and the likes will not allow the CDO to work against their servers.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I wonder if my previous failed attempts using Gmail and CDO were because I did not include smtpusessl = True.
Got it! Would have helped had I stumbled upon the various configuration fields, like what ItsMe referenced: smtpusessl = True
I noticed the code from blue-claw didn't include the statements:
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 'CDO Source Defaults
Set Flds = iConf.Fields
Thanks to all,
Bill
So you got it to work with Gmail? I had given up on using it with Gmail and I could probably use that in a couple of apps.
Yes, exactly like the function appears on Blue-Claw. Appropriate substitutions made of course.
Thanks,
Bill
I use it with Gmail without a problem although I suspect if you try to send 1000's of emails it would probably object.Code:So you got it to work with Gmail?
Not had a need to try it yet, but here is a link for retrieving emails - VB6 but I'm sure an easy convert to VBA
https://www.emailarchitect.net/eaget.../vb.aspx?cat=5