Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access selected email in Outlook from VBA

Status
Not open for further replies.

lxn

Programmer
Jan 29, 2002
53
CA
Hi, all:
I ran into some problems, I hope someone can help me solve this.
I'm currently developing an application, and a part of it will allow the users to open Outlook from the application and save the attachment of selected email to the HD.
After some work, I'm able to create the code which will automatically save the attachment of the first email item of the inbox (if it has an attachment), or I could loop through the whole inbox folder and do the same for all of the email items with attachments. But that is not what I wanted to achieve. What I want to do is to allow the user to only save the attachment of the email item that is selected in the inbox. And since it's random as to which email item will be selected, there's no way for me to determine the email item using the .items(index).
I was wondering if there's any method that's similar to a list box or combo box, such as .ItemIndex or ItemSelected and such, that will allow me to find out the index of the selected email item in the inbox.

here's some of the code I used:

Set lobjOutlook = CreateObject("Outlook.Application")
Set lobjFolder = lobjOutlook.activeexplorer.CurrentFolder
Set lobjItems = lobjFolder.items
Set lobjAttachments = lobjItems(1).attachments
lobjAttachments.Item(1).saveasfile &quot;<path name>&quot;

this will save the attachment of the first email item in the inbox. So I'm looking for something that might look like:
Set lobjAttachments = lobjItems(ItemSelected).attachments

please, if anyone can help me out in anyways, please give me some advices. Many thanks in advance.

Merlin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top