• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1027
  • Last Modified:

Fetching the full path of Outlook email attachement with .NET

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
__geof__
Asked:
__geof__
  • 4
  • 2
1 Solution
 
kdwoodCommented:
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
 
__geof__Author Commented:
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
 
kdwoodCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
__geof__Author Commented:
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
 
__geof__Author Commented:
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
 
michael2705Commented:
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
 
__geof__Author Commented:
I search for a long time now without anything better. I think we can close the discussion without any solution. :(
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now