Solved

Fetching the full path of Outlook email attachement with .NET

Posted on 2008-10-21
7
997 Views
Last Modified: 2013-11-10
Hi everyone.

I am trying to create an Add-in to outlook that gets the attachement and send the to another program. I'm using VB and I attach the relevant part of the code.

My problem is that  the string is empty. So my question is: How can I get the full path of the attachment?

For info, I test with Outlook 2007 and develop on Visual Studio 2008.
Dim currentMailItem = CType(Me.Application.ActiveInspector().CurrentItem, Outlook.MailItem)
For i = 1 To currentMailItem.Attachments.Count
Dim fileString As String = currentMailItem.Attachments.Item(i).PathName
Next i

Open in new window

0
Comment
Question by:__geof__
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 10

Expert Comment

by:kdwood
ID: 22772351
Greetings geof,

I may be wrong, but I don't think you can do it that way.  The attachment is stored in the Outlook item itself and is accessible only through that item's Attachments collection. The Attachment.PathName property is relevant only for linked files that have the type OlByReference.

I think you will need to save the attachment to disk and then interact with it.

See if this link will help:

http://www.codeproject.com/KB/office/OAE.aspx

Regards,

Keith
0
 
LVL 6

Author Comment

by:__geof__
ID: 22774179
That is the workaround I am working with now but the problem is that I sometimes need a lot of diskspace and I want to avoid it.

Is there no possibility to get the path of the attached file?
0
 
LVL 10

Expert Comment

by:kdwood
ID: 22781006
Can you give me a better idea of what you are trying to do with the attachment?  This may give me a few ideas.

Thanks,

Keith
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 6

Author Comment

by:__geof__
ID: 22781577
I need them to use in a Shell call to a batch file.
It is a program that sends files and it needs the path of every file to send. Allows you to send i.e. 100GB or more. And I just want to make an outlook add-in for our employees.
0
 
LVL 6

Author Comment

by:__geof__
ID: 22880318
It does't look like there is any solution. I actually copy the attachement to a temporary folder where I can fetch them and remove them afterwards. It is not a good solution but it looks like the only one.
0
 

Expert Comment

by:michael2705
ID: 23366918
I think geof is right. I coudn't find another way yet. Here's the code I use:
my_AddIn.eMail.Attachments[i].SaveAsFile(my_file_path_for_attachment);	

Open in new window

0
 
LVL 6

Accepted Solution

by:
__geof__ earned 0 total points
ID: 24242642
I search for a long time now without anything better. I think we can close the discussion without any solution. :(
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question