How to find path of attachment

G

Guest

I have written a script that strips an attachment from selected e-mail
messages and puts the file name of the deleted attachment in the body of the
e-mail. Is there a way to also have it put the pathname (folder) from where
the file was attached? I have this statement defined in the script, but it
only gives the file name and not the path where the file came from:

strFile = objAttachments.Item(i).PathName & objAttachments.Item(i).FileName

Is there a way to have it find the folder also?

I have some experience with vb, but not enough, I guess.

TIA.

- Steve
 
D

Dmitry Streblechenko

Outlook does not remember the pathname unless the attachment is by reference
rather than by value.
Think about it tthis way: if you receive a message from somebody else, how
would Outlook know (or care) what was the original path on the sender's
machine?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

What do you mean "Outlook does not remember the pathname unless the
attachment is by reference rather than by value." Can I attach documents ina
way that would facilitate Outlook remembering the pathname?
 
D

Dmitry Streblechenko

If you call
Attachments.Add "c:\temp\filename", olByReference
you will get an attachment by reference, in this case Outlook won't store
the actual data, only a link to the file. It is totally useless if you send
it to somebody and the path does not point to a network path where it can be
accessed from the recipient's machine.
If you use olByValue, Outlook will store the file data and the file name,
but not the path name.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

I don't want to send it to anyone. I want to do the following:

I send an e-mail with an attachment to someone. A copy of the e-mail with
the attachment goes into my Sent Mail folder. I want the e-mail to remain in
the Sent Mail folder, but just with a reference to the attachment, not the
actual attachment, which is really somewhere in My Documents. The attached
file is stripped from the e-mail message. I would like the path and file name
to be inserted into the e-mail message that is in the Sent Mail folder, so I
know what was sent and from which folder.

I have written a vb script that does all of that, except for the path name.
As you pointed out, Outlook does not use the path name for that. Is there a
way to get it for this script?

Thanks again.

- Steve
 
D

Dmitry Streblechenko

No, Outlook still does not remember the full path. For all practical
purposes, the directory can be deleted even before the message is submitted
..
Outlook does fire the events when attachments are added, but they still
won't give you the path.
You can still of course save the attachments from the Sent Items folder,
delete the attachments, then re-add them as olByReference.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

Thanks. I will give it a try.

- Steve

Dmitry Streblechenko said:
No, Outlook still does not remember the full path. For all practical
purposes, the directory can be deleted even before the message is submitted
..
Outlook does fire the events when attachments are added, but they still
won't give you the path.
You can still of course save the attachments from the Sent Items folder,
delete the attachments, then re-add them as olByReference.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top