What data type is olMi declared as? When iterating through an Items collection,
it is best to use a variable declared as a generic Object type because
of all the different message types that you can encounter. Or else check
the .Class property to see what kind of object it is before processing
it further.
Eric Legault - B.A, MCP, MCSD, Outlook MVP
---------------------------------------------
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/
>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
>
>