+ Reply to Thread
Results 1 to 6 of 6

How To Insert/Embed Outlook Email into excel worksheet using VBA

  1. #1
    Registered User
    Join Date
    10-06-2020
    Location
    Chennai
    MS-Off Ver
    2016
    Posts
    9

    How To Insert/Embed Outlook Email into excel worksheet using VBA

    Hi Folks,

    I would need your help to insert the outlook email message(saved in the same path as of my macro file) into the excel worksheet.

    I tried recording the macro and altering the code with a dynamic path and it ended up with the runtime error -> " xxx(output email name).msg:: File format invalid".

    My VBA code:
    Please Login or Register  to view this content.
    Please help out!


    Thanks
    Last edited by Keers1; 05-22-2022 at 09:31 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: How To Insert/Embed Outlook Email into excel worksheet using VBA

    You have multiple problems on this line of code:

    Please Login or Register  to view this content.
    What is the data type of Email? On this line you are trying to use it as an object but in later you are trying to use it as a String.

    In any case, you are trying to open an Outlook email as if it were an Excel file, and that just won't work. That is why you are getting the error.

    I would try this. I have not tested it.
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-06-2020
    Location
    Chennai
    MS-Off Ver
    2016
    Posts
    9

    Re: How To Insert/Embed Outlook Email into excel worksheet using VBA

    Hi Jeff,

    Thanks for your code!

    I have used Email -> to assign the email name (as a reference) using a set keyword, similar to a worksheet reference say eg: set wk = XPath & "\temp.xlsx".

    As per my requirement, I would need to attach the email to the worksheet which is in the same folder as my macro excel file. Now, I understood why the error occurred based on your comments.

    I tried your code and it works fine. Thanks again.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: How To Insert/Embed Outlook Email into excel worksheet using VBA

    Quote Originally Posted by Keers1 View Post
    I have used Email -> to assign the email name (as a reference) using a set keyword, similar to a worksheet reference say eg: set wk = XPath & "\temp.xlsx".
    This is incorrect. The Set keyword is used to cause an object variable to reference the same object on the other side of the "=" sign. For example:

    Please Login or Register  to view this content.
    You cannot use the Set keyword to assign a String to a Worksheet object or any other object.

  5. #5
    Registered User
    Join Date
    10-06-2020
    Location
    Chennai
    MS-Off Ver
    2016
    Posts
    9

    Re: How To Insert/Embed Outlook Email into excel worksheet using VBA

    Hi Jeff,

    Sorry for late reply!

    Existing step:
    I would need your help to insert the outlook email message(saved in the same path as of my macro file) as object into the excel worksheet.

    Please Login or Register  to view this content.
    Addiontal task:
    1) I would need to attach 3 more files in the same email message which i am about to add as object in VBA excel worksheet.
    2) Name of the email message and workbooks to be attached should be dynamic (all the files will be saved in same folder of macro file).


    Please help out

  6. #6
    Registered User
    Join Date
    10-06-2020
    Location
    Chennai
    MS-Off Ver
    2016
    Posts
    9

    Re: How To Insert/Embed Outlook Email into excel worksheet using VBA

    Dear jeff and other Folks,

    Please share your comments/suggestions regarding this thread. let me know if you need any clarity in the requirements.

    Thanks for your help in advance!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to open a new Outlook email by filling some range of an excel worksheet using VBA?
    By 1tane1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2014, 08:02 AM
  2. Embed a picture as a signature in an Outlook email generated by VBA in Excel
    By zach.sauls in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2013, 11:10 AM
  3. [SOLVED] VBA - Save, and Embed in Email (Outlook)
    By jlo33 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-19-2013, 10:10 AM
  4. Replies: 1
    Last Post: 11-01-2012, 10:00 AM
  5. [SOLVED] insert a hyperlink into an excel cell to refer to a specific email in outlook
    By Joe McLoughlin in forum Excel General
    Replies: 3
    Last Post: 08-03-2012, 05:25 PM
  6. Copying Excel worksheet in Outlook email body
    By xatomicx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-30-2010, 01:38 PM
  7. [SOLVED] How do you embed an Outlook e-mail into Excel Spreadsheet?
    By J. Sheppard in forum Excel General
    Replies: 0
    Last Post: 04-25-2006, 11:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1