none
Can you programmatically attach a file to an existing Outlook email ? RRS feed

  • Question

  • I have an existing email open, I would like to programmatically attach a file to it.
    Can you programmatically attach a file to an existing Outlook email ?
    Friday, January 6, 2017 6:53 PM

All replies

  • I have an existing email open, I would like to programmatically attach a file to it.
    Can you programmatically attach a file to an existing Outlook email ?
    Friday, January 6, 2017 6:54 PM
  • Hello,

    Yes, you can get the currently opened email by using the ActiveInspector method of the Application class which returns the topmost Inspector object on the desktop. Use this method to access the Inspector object that the user is most likely to be viewing. For example:

    Sub CloseItem() 
     Dim myinspector As Outlook.Inspector 
     Dim myItem As Outlook.MailItem 
    
     Set myinspector = Application.ActiveInspector  
     Set myItem = myinspector.CurrentItem 
     myItem.Close olSave 
    End Sub 

    Then you can attach a file by using the Attachments.Add method. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Saturday, January 7, 2017 10:02 PM
  • should be possible only in email either in new  or edit/forward mode. Then you can send/save the email. 

    What is the purpose of adding file in the existing received email.


    Thanks, Ashish | Please mark a post helpful/answer if it is helpful or answer your query.

    Sunday, January 8, 2017 1:47 AM
  • Hi aujong,

    I find that you had create a duplicate thread for the similar issue.

    so to avoid duplication of threads I merge these two threads together.

    you can refer the suggestion given by Eugene  Astafiev may solve your issue.

    if you have further question regarding the same issue then please let us know about that.

    we will try to give you suggestion on that.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 9, 2017 5:13 AM
    Moderator
  • Thank you Eugene  Astafiev. That works.
    Monday, January 9, 2017 6:33 PM
  • You are welcome! Good luck with your Outlook solution.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, January 9, 2017 7:34 PM
  • Hi aujong,

    From your last post, I can see that your issue is solved now.

    but you did not mark the suggestion given by Eugene  Astafiev as an answer.

    this case is still open.

    if you do not mark the answer then this case will be open forever.

    so I suggest you to mark the answer and help us to close this thread.

    Regards

    Deepak 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 10, 2017 3:19 AM
    Moderator