PDA

View Full Version : Automaticly open selected email and set it in forward modus an to save it on the HDD



lio_46
09-20-2012, 12:17 AM
Hello


I'm new in the VBA programming and I have an issue with email handling on my computer.

The situation is like that: I got in my mailbox several encrypted emails with s/mime. My initially intention was to have a decrypted version/copy of each email and than to store those on my local HDD.
After long searches I had to admit, that I'll only reach my idea with a workaround, because of the encryption stuff.
My workaround works like this: Open the email, click the forward button, and save the "forward" email as .msg .

Now, i was looking for a script or similar to automate this work. What I found until now is a VBA script to get the current email info and second script to take the info in a forward email. as you can see below....

***************************************************
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = _
objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = _
objApp.ActiveInspector.CurrentItem
Case Else
End Select
End Function

*************************************************
Sub ForwardA()
Dim objMail As Outlook.MailItem
Set objItem = GetCurrentItem()
Set objMail = objItem.Forward
objMail.To = "(E-Mail Removed)"
objMail.Display
Set objItem = Nothing
Set objMail = Nothing
End Sub

*****************************************************

It would be very nice if you could help me with this above mentioned issue!!

The final script should automatically run for each email in the mailbox(loop):
-get the current selected email
-generate an email in forward modus
-save the "forwarded" email on the machine


Thanks,
Regards
Lio