Trying to write a program that would collect images received as email attachments

  • Thread starter Thread starter Vanessa Lee
  • Start date Start date
V

Vanessa Lee

Hello,

Desperately, I am trying to find a way to write a program that would collect
images received as email attachments and save them to a specific folder with
a changed filename into whatever was the subject of that email. There would
be one image per email.

Here is how I think it would work:

(1) Receive an image in email attachment.
(2) Retrieve the image from that attachment.
(3) Change the name of the image file into what was written in the Subject
of that email.
(4) Save the renamed image file into a specific folder.
(4) Delete the received email

I have done some research and found that the application would need to
interact with MAPI. Could you please tell me if you have seen any similar
programs written in VBScript somewhere on the internet, or could you give me
some very specific advice or directions.

P.S. I have my own Windows 2003 server, and can install anything on my
server if I need to.

Thank you,
Vanessa Lee
 
Vanessa said:
Hello,

Desperately, I am trying to find a way to write a program that would collect
images received as email attachments and save them to a specific folder with
a changed filename into whatever was the subject of that email. There would
be one image per email.

Here is how I think it would work:

(1) Receive an image in email attachment.
(2) Retrieve the image from that attachment.
(3) Change the name of the image file into what was written in the Subject
of that email.
(4) Save the renamed image file into a specific folder.
(4) Delete the received email

I have done some research and found that the application would need to
interact with MAPI. Could you please tell me if you have seen any similar
programs written in VBScript somewhere on the internet, or could you give me
some very specific advice or directions.

P.S. I have my own Windows 2003 server, and can install anything on my
server if I need to.

Thank you,
Vanessa Lee
 
Desperately, I am trying to find a way to write a program that would collect
images received as email attachments and save them to a specific folder with
a changed filename into whatever was the subject of that email. There would
be one image per email.

Here is how I think it would work:

(1) Receive an image in email attachment.
(2) Retrieve the image from that attachment.
(3) Change the name of the image file into what was written in the Subject
of that email.
(4) Save the renamed image file into a specific folder.
(4) Delete the received email

I have done some research and found that the application would need to
interact with MAPI. Could you please tell me if you have seen any similar
programs written in VBScript somewhere on the internet, or could you give me
some very specific advice or directions.

P.S. I have my own Windows 2003 server, and can install anything on my
server if I need to.

As for an external program or a VB Script for this purpose: point (1)
confuses me. E-mail is received by Outlook/Exchange, and I can't see an
easy way around that. However, within Outlook, the following code might
get you started:

Dim objFS As Object
Dim itmMail As MailItem
Dim myAtt As Outlook.Attachment
Dim strDir As String
Dim strSuffix As String
Dim blnSaved As Boolean

strDir = "C:\Temp\"
Set objFS = CreateObject("Scripting.FileSystemObject")
For Each itmMail In ActiveExplorer.Selection
blnSaved = False
For Each myAtt In itmMail.Attachments
strSuffix = objFS.GetExtensionName(myAtt.FileName)
myAtt.SaveAsFile (strDir & itmMail.Subject & "." & strSuffix)
blnSaved = True
Next myAtt
If blnSaved Then
'itmMail.Delete ' Activate this when you're really sure about it.
End If
Next itmMail

Note that this will overwrite existing files of the same name without
warning.
 
Vanessa, did you want to write this yourself or are you looking for a
packaged solution? It's a little involved but not terribly complicated to
code this (Michael Bednarek's follow up is a good starting point). If you
have problems after you get started, post back and we can help you with the
programming.

Otherwise (shameless plug begins), I have a product that provides similar
attachment handling capabilities (see my signature).
 
Back
Top