Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    mapi.session (emailing via CDO)

    I'm trying to run some sample code wherein I get an error on the set statement for the mapi.session object. See attached screenshot wherein I've added the current references.



    Any ideas as to what is missing?

    Thanks,
    Bill

    Click image for larger version. 

Name:	MAPI.Session.jpg 
Views:	27 
Size:	173.0 KB 
ID:	22261

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    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.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    June, your schemas got truncated when the hyperlink was automatically applied.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    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.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    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.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Google Mail, yahoo mail, and the likes will not allow the CDO to work against their servers.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    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.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    I wonder if my previous failed attempts using Gmail and CDO were because I did not include smtpusessl = True.

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    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

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    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.

  14. #14
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, exactly like the function appears on Blue-Claw. Appropriate substitutions made of course.
    Thanks,
    Bill

  15. #15
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Code:
    So you got it to work with Gmail?
    I use it with Gmail without a problem although I suspect if you try to send 1000's of emails it would probably object.

    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

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Seeking guidance with session database
    By melliott1712 in forum Access
    Replies: 5
    Last Post: 10-06-2014, 12:21 AM
  2. Emailing
    By fastebs in forum Access
    Replies: 2
    Last Post: 04-13-2012, 12:37 AM
  3. Session variables
    By accessnewb in forum Programming
    Replies: 5
    Last Post: 08-04-2011, 11:45 PM
  4. Replies: 6
    Last Post: 11-18-2010, 04:00 AM
  5. Replies: 0
    Last Post: 11-28-2005, 01:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums