Save attachment and decrypt

A

Adam S.

Hi all

I am fairly new to VBA, and need some help directions:
I have a dedicated account to receive encrypted gpg and pgp
attachments
I would like to create a rule that will save the attachments as they
come, say to u:\newmail, and than decrypt and print the message to the
default printer in a secured room.
Should this be broken to save, decrypt, print?
or all in one script?
Are there any built in rules to save attachments in Outlook and print
them?

TIA
 
A

Adam S.

Hi all

I am fairly new to VBA, and need some help directions:
I have a dedicated account to receive encrypted gpg and pgp
attachments
I would like to create a rule that will save the attachments as they
come, say to u:\newmail, and than decrypt and print the message to the
default printer in a secured room.
Should this be broken to save, decrypt, print?
or all in one script?
Are there any built in rules to save attachments in Outlook and print
them?

TIA

Revision.
I found the code that saves the attachment to a network drive, but I
also need to move the attachmentless e-mail to a different folder
after the extraction.
After I move it, I need to trigger a batch file for the decryption.
Any help is appreciated.
 
K

Ken Slovak - [MVP - Outlook]

How you do that depends on whether you intend to move the items to only one
folder or different folders, and where the target folder is located.

For example, say you want to move all items you've processed to a subfolder
of Inbox named "Foobar". In that case you would code like this:

Dim oNS As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder

' Application only works in the Outlook VBA project
' as the Outlook.Application object.
Set oNS = Application.GetNameSpace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderInbox).Folders.Item("Foobar")

Once you have your target folder reference you'd use it like this:

Dim oMail As Outlook.MailItem

' oSource is the source email item
Set oMail = oSource.Move(oFolder)

You can then release that object or work with oMail as the newly moved item.
 
A

Adam S.

How you do that depends on whether you intend to move the items to only one
folder or different folders, and where the target folder is located.

Ken

Thanks for replying, yes it is one folder only.
What if I just wanted to delete after processing? Oddly enough, when I
create a rule wizard, it will delete before the script is running...
No way to change the order.
 
K

Ken Slovak - [MVP - Outlook]

If you want to delete the item then just call the Delete method on the item
and not the Move method.
 
A

Adam S.

If you want to delete the item then just call the Delete method on the item
and not the Move method.

How do I do it and moving to the next e-mail after the delete?
 
K

Ken Slovak - [MVP - Outlook]

Move to which next email? Do you mean the next one in the Items collection
or the next one in the current view?

You don't really know which is the next item in a view and there's no way to
get that. You can try to simulate that if you know the current view and its
sorting settings, then you can sort the Items collection based on those sort
criteria, but if there are any special groupings of the view that still
might not do what you want. Normally the view will update once an item is
deleted to show the next or previous item automatically based on the user
settings.
 

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