+ Reply to Thread
Results 1 to 2 of 2

Reference to Selected Attachment

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    24

    Reference to Selected Attachment

    Hi

    How do I get a reference to a selected attachment or even selected attachments in an email?

    I want to be able to look at an email, selected one or more, but not all, of the attachments and run a macro and so something with those selected attachments. I can reference the email and I can reference all of the attachments individually but how can I tell if a specific attachment is selected?

    Dim oitem As MailItem

    Set oitem = GetCurrentItem

    Set atts = oitem.Attachments


    For Each att In atts

    .... this is where i need something like

    if att.selected then
    .... do soemthing
    end if

    Next

    Many thanks


    Max

  2. #2
    Registered User
    Join Date
    01-18-2021
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    6

    Re: Reference to Selected Attachment

    if you know the name of the attachment you can just use .attachments.name
    if you want the file type you can check for instr(atts.displayname, ".xxx")



    Public save_attachment(oitem as outlook.item)
    Dim atts as outlook.attachment
    Dime SaveFolder as String, SaveFolder = "c:\"

    for each atts in oitem.attachments
    if atts.name = "BLABLABLA" then ''You can use Displayname too. I cant remember which return then .xxx
    atts.saveasfile savefolder & atts.name
    end if
    next atts

    oh almost forgot.
    after you done with the file just use the kill to remove the file.

+ 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. Dynamic Range Reference (with Attachment)
    By amjadziyard in forum Excel General
    Replies: 1
    Last Post: 09-09-2019, 11:43 AM
  2. Error in mailing of a file as attachment in my selected folder path
    By Vcare in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2017, 07:33 AM
  3. Email Dialog Box Selected Excel attachment
    By ciaran01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2014, 02:54 AM
  4. Copy selected range from email attachment and paste into closed workbook
    By Lisa4legin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2013, 09:32 AM
  5. [SOLVED] send attachment selected in userform to a specific cell
    By jjyoung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2013, 04:14 PM
  6. [SOLVED] Looping Email- Multiple Attachments but I Only Want Selected Attachment
    By cschoyer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-02-2012, 09:16 AM
  7. Email selected worksheets from a workbook as attachment.
    By osoloco in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-27-2006, 08:20 PM

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