Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Unanswered: Sendmail not working in Access2007

    Hi,
    This procedure always worked fine in Access2003, but it does nt in Access2007.
    Anyone can point out what is wrong? Or maybe has a working piece of code?
    Code:
    Private Sub Exportmail_Click()
    
    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    Dim objOutlookRecip As Object
    Dim objOutlookAttach As Object
    Dim AttachmentPath
    Dim DisplayMsg
    
              ' Create the Outlook session.
              Set objOutlook = CreateObject("Outlook.Application")
    
              ' Create the message.
              Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
              With objOutlookMsg
                  ' Add the To recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("one@site.bla")
                  objOutlookRecip.Type = olTo
    
                  ' Add the CC recipient(s) to the message.
                  'Set objOutlookRecip = .Recipients.Add("")
                  'objOutlookRecip.Type = olCC
                  
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "Export wedstrijd"
                 .Body = "Export van wedstrijd" & vbCrLf & vbCrLf
                 .Importance = olImportanceHigh 'High importance
    
                 ' Add attachments to the message.
                 AttachmentPath = Application.CurrentProject.Path & "\Export.xls"
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                .Display
                .Save
                .Send
              End With
              Set objOutlook = Nothing
        End Sub
    Would be nice if this also worked in 2003 version.. (the DB is used by several people using different versions..)

    Thanks

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    There is some known issue with SendMail and Access 2007. It's probably that.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jun 2009
    Posts
    3
    Is there no work around available? Or other approach perhaps..?

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I personally choose to bypass Outlook altogether. Might be an option to consider?

    What line of code is throwing which error?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jun 2009
    Posts
    3
    Thanks StarTrekker,

    Error is on this line:
    Code:
    Set objOutlookRecip = .Recipients.Add("one@site.bla")
    I think I'l have a try with the SMTP option from other post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •