Results 1 to 4 of 4
  1. #1
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142

    Send and SAVE outlook .msg email from Access VBA

    I need to be able to send an outlook email from access and then save outlook's resulting .msg file to the computer. I understand how to code sending the email, but how do I then save it.
    After sending would I have to then loop through the sent items folder for my msg and then save it that way. Does anyone have any example code?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Ok so now the issue is after I send the email if I try to run the SaveAs method it'll throw an error. "The object has been moved or deleted."
    Am I going to have to loop through my sent mail folder to find the email I just send then save it?

    [EDIT]

    Ok so I've come up with a way to loop through the sent items mailbox to find my email and then save it. If anyone has a more efficient method I would love to hear it.

    Code:
    For Each outlookMailItem In outlookApplication.GetNamespace("MAPI").Folders("Work").Folders("Sent Items").Items.Restrict("[Subject] = """ & email_subject & """")
      If outlookMailItem.Subject = email_subject Then
        om.SaveAs "C:\testing\test.msg"
        Exit For
      End If
    Next om
    I guess I'll have to come up with a scheme to uniquely tag each email to then search by.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Send Email via Outlook from an Access form
    By ramirezx@ddmfg.com in forum Programming
    Replies: 3
    Last Post: 07-11-2018, 11:22 AM
  3. Replies: 15
    Last Post: 10-17-2015, 07:02 AM
  4. Replies: 5
    Last Post: 04-25-2013, 10:36 AM
  5. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 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