Consulting

Results 1 to 3 of 3

Thread: Add Attachment Filename to Body of E-mail

  1. #1

    Add Attachment Filename to Body of E-mail

    Does anybody know how to add a notation to the body of an e-mail which will add the filename of an attachment right before the signature block when it is dragged or otherwise added to an e-mail.

    For example, if user drags two file named:

    bts-2009-01.doc and bts-2009-02.doc

    to a message, outlook will add the text:

    <<bts-2009-12-09213.doc>>
    <<bts-2009-12-09213.doc>>

    to the bottom of the message right before the signature block.

    Thanks.

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Do you wish to add the annotation while the email is being created or when it is sent. The approach would be much the same, however:
    • if the former, you would probably use a stand alone procedure that you would have to activate manually
    • if the latter, you could include the relevant code in the Application_ItemSend procedure (which executes automatically when you send an email).
    I recommend that latter because that way it only runs once and you do not have to add code to check if the procedure has already been run on the target mail item. while you are thinking about this, I will rough out some code to do what you want.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    I looked at how this might be done. I will use the abbreviation ANAP (Attachment Name Add Procedure) to refer to the procedure or macro that does what you want. A few things already found:
    • Identifying the attachments and their names is fairly easy.
    • Adding that to the body of the email looks easy as long as the email body does not have elegant formatting (more about that below)
    • As mentioned in my first reply, calling the ANAP from the Application_ItemSend procedure simplifies things because the ANAP is only called once and the ANAP does not have to figure out if it has already been called for this mail item, or if the target mail item is open for editing or just an item in a folder. But see #5 below
    There are some problems yet to be resolved:
    1. there are different types of attachments, e.g., normal attachments like files that are discrete items vs embedded attachments like pictures, icons, etc. I assume that you are only interested in normal attachments. Please comment on what you want to ANAP to do here.
    2. mail items that are an accumulation of previous items may have multiple instances of the target signature block and multiple instances of the ANAP having been run. I assume that you wish the ANAP to work with current attachments and the "most recent" signature block. That probably means the first signature block encountered in the mail item's body.
    3. Outlook suppports multiple signature blocks and a different block for NEW messages vs REPLYs and FORWARDs. So, the ANAP must keep track of that (and probably interrogate Outlook for the current signature block being used). That will be interesting to explore
    4. If the mailitem format is Plain Text, inserting the attachment names is a simple text insert operation: the ANAP scans for the first (see above) occurance of the signature block and inserts the attachment names. But if the format is RTF or HTML, a more careful approach is required to ensure that formatting is not lost.
    5. even if we call the ANAP from the Application_ItemSend procedure, the ANAP could be called twice for the same mail item. For example, it the Outbox were not cleared and the item resent, the ANAP would probably be called twice. Not a big issue.
    The bottom line is that this is probably more difficult than it looks so it may take some time to create what you want.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

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