Results 1 to 4 of 4
  1. #1
    PianistChris is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2013
    Posts
    2

    Question Access 97 Sending a Report to Outlook with Problems

    Hello,

    I have a report that converts to .pdf with one button in my form and is saved in a set location.
    What I would like is another button that you click which finds the file (This worked alright), and then open outlook and fills in the body, subject and the signature automatically.

    What I tried was creating a module with the code further down below on this post, and then adding it the to the button and it seemed to work fine; it opened a new outlook message and allowed me to send it, however there were a few problems to this:



    - The code will not work if Outlook is already open, if it is open I get this error: 'Run-Time error '429', Could not create object'.
    - The signature will not be added to the Outlook message, even though in my outlook I have a .htm signature as default.
    - The message will not send until I open Outlook - So Outlook is never opened, just a new message, and I cannot have outlook open or it will not work.

    I have tried using both objOutlook = New Outlook.Application and objOutlook = CreateObject(''Outlook.Application"), but the first only runs when Outlook is closed, and badly, and the second comes up with the same error as above when I try it with Outlook open, and this error when Outlook is closed: 'Run-Time error '438', Object doesn't support this property or method'.

    Here is the code I use in the module:
    Code:
    Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
              Dim SigString As String
              Dim Signature As String
    
    
              ' Create the Outlook session.
              Set objOutlook = New Outlook.Application
              
              ' Create the message.
              Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
    
              With objOutlookMsg
    
    
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "This is an Automation test with Microsoft Outlook"
                 .Body = "This is the body of the message." & vbCrLf & vbCrLf
                 .Importance = olImportanceHigh  'High importance
                 .a
                 
                 ' Add attachments to the message.
                 If Not IsMissing(AttachmentPath) Then
                     Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                 End If
    
    
                 ' Resolve each Recipient's name.
                 For Each objOutlookRecip In .Recipients
                     objOutlookRecip.Resolve
                 Next
    
    
                 ' Should we display the message before sending?
                 If DisplayMsg Then
                     .Display
                 Else
                     .Save
                     .Send
                 End If
    I am also using MS Access 97 for the databases and reports, and Outlook 2003 to send messages.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I use the CreateObject method with Access 2007 and 2010 without error when Outlook is already open.

    However, I don't attach signature, I should try that.

    Sorry, never used Access 97.

    Might be incompatibility between Access 97 and Outlook 2003. Maybe late binding will work. That does not require setting VBA reference library. http://word.mvps.org/faqs/interdev/e...atebinding.htm
    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
    PianistChris is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jul 2013
    Posts
    2
    Quote Originally Posted by June7 View Post
    I use the CreateObject method with Access 2007 and 2010 without error when Outlook is already open.

    However, I don't attach signature, I should try that.

    Sorry, never used Access 97.

    Might be incompatibility between Access 97 and Outlook 2003. Maybe late binding will work. That does not require setting VBA reference library. http://word.mvps.org/faqs/interdev/e...atebinding.htm
    Thanks, I've tried: GetObject, CreateObject and New and all do not work, and continue to come up with errors, such as 'can't create object' or 'expression not defined'. It only seems to want to work when Outlook is closed.

    I think it might be a compatibility issue. If Outlook is closed then it creates a normal email, but it does so without a signature. I have fixed this by adding code that forces it to use Outlook's default signature, but at the same time, the email will not send unless I click send and then open Outlook.

    When Outlook is open the Access 97 is probably create a new email, but because its not in the same version of Outlook 2003, it crashes. Any ideas on this?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If late binding doesn't work then the only option I see is Access upgrade.
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sending HTML files via Access to Outlook
    By Yann63 in forum Programming
    Replies: 4
    Last Post: 02-13-2014, 05:34 PM
  2. Sending several emails causes Outlook crash
    By mercapto in forum Programming
    Replies: 3
    Last Post: 06-14-2013, 07:30 AM
  3. Sending .pdf in Outlook
    By Stephanie53 in forum Forms
    Replies: 65
    Last Post: 05-01-2013, 08:04 AM
  4. sending data into an email body - outlook
    By webisti in forum Access
    Replies: 6
    Last Post: 02-15-2012, 07:05 AM
  5. Replies: 3
    Last Post: 09-01-2010, 08:43 PM

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