Automating saving encrypted attachments in Outlook 2000 using VB

J

j

Hi,
After having a look around on various groups I found lots of code to
automate the saving of attachments on mails to folders on the file
system. This was the primary requirement of a client of mine. However,
they have now come back to me to say that the format of the mails will
be changing to SMIME encrypted emails. They are using Outlook 2000 and
have got personal certificates from Thawte and now have an automated
system emailing them mails that are encrypted using these
certificates. I'm trying to work out if I'll be able to access the
attachments if they are encrypted. I've got a personal cert myself now
and I'm coming up against some problems in my code (abridged version
below)

For I = Fldr.Items.Count To 1 Step -1
Set olMi = Fldr.Items(I)
For Each olAtt In olMi.Attachments
On Error Resume Next
olAtt.SaveAsFile (strPath & olAtt.filename)
Next olAtt
olMi.Save
olMi.Move MoveToFldr
Next I

I'm getting an error on the line of "Set olMi = Fldr.Items(I)"
Run-time error '13':
Type Mismatch

This error doesn't happen when the mail is an unencrypted mail. Does
this mean that encrypted mails are not Outlook.MailItem objects or
what???
Does anyone know whether even if I can get the type right, will I be
able to save the attachment? Normally when I open the mail I get
prompted for a password (this was associated with the cert when I went
through the cert generation process on Thawte.com). How will I be able
to automate this process so that it is invisible to the user?

Any help, ideas, references would be greatly appreciated.

Regards,
Jeremy
 
S

Sue Mosher [MVP-Outlook]

Outlook provides no programmatic way to access encrypted information. You
can determine what type of item you're working with by declaring olMi as
Object, not MailItem, and checking its Class property.
 
J

j

Thanks for your response Sue. I gather from your response then that
this type issue is only the first of my problems i.e. even if I can
get the code to stop bombing at each encrypted mail, I'll still have
problems saving off the attachments assoicated with these mails. Am I
right? If I can't do this with the Outlook object model/API, do you
(or anybody else) have any suggestions for alternative approaches?

Whatever approach I take must also try to avoid the security errors
that crop up when trying to automate mail manipulation. BTW I'm not
trying to SEND mails, just trying to save off their attachemtns and
move mails into various sub folders. I'm not sure that this makes any
difference to the security monitor within Outlook but I thought I
should mention just it in case.

Anyway,
Thanks again,
J
 
S

Sue Mosher [MVP-Outlook]

I don't know of any alternatives for accessing the encrypted attachments.
There are certainly none within the Outlook object model.

Outlook will trigger security prompts when you use any method that could be
used to harvest email addresses from messages. See
http://www.outlookcode.com/d/sec.htm for ways to avoid them.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



j said:
Thanks for your response Sue. I gather from your response then that
this type issue is only the first of my problems i.e. even if I can
get the code to stop bombing at each encrypted mail, I'll still have
problems saving off the attachments assoicated with these mails. Am I
right? If I can't do this with the Outlook object model/API, do you
(or anybody else) have any suggestions for alternative approaches?

Whatever approach I take must also try to avoid the security errors
that crop up when trying to automate mail manipulation. BTW I'm not
trying to SEND mails, just trying to save off their attachemtns and
move mails into various sub folders. I'm not sure that this makes any
difference to the security monitor within Outlook but I thought I
should mention just it in case.

Anyway,
Thanks again,
J


"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Outlook provides no programmatic way to access encrypted information. You
can determine what type of item you're working with by declaring olMi as
Object, not MailItem, and checking its Class property.
 

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

Similar Threads


Top