Decrypt mail to Exchange public folder

0

I have received some encrypted mails. I want to store them in an Exchange public folder. The mails shall be stored decrypted so that others can read them without the need for my private key certificate.

Using the Outlook GUI it's possible to do so using the Forward action with encryption disabled. This has the drawback that the sender of the mail is replaced with my address. Not so good, but at least the mail encryption is removed.

My Outlook is configured to use two accounts. The default account is an external POP3 account. But the mail shall be forwarded directly to the Exchange server. Therefore I want to overwrite the SendUsingAccount property of the mail. But this causes an error with the Exchange server.

$Exchange="name-of-the-server"
$PublicFolderAddress="address-of-the-folder"
$Outlook = New-Object -ComObject OUTLOOK.APPLICATION
$Account = $Outlook.Session.Accounts | Where-Object { $_.ExchangeMailboxServerName -eq $Exchange }
$Namespace = $Outlook.GetNamespace("MAPI")
$Mailbox = $Namespace.Folders | Where-Object { $_.Name -eq "my-mail-address" }
$Inbox = $Mailbox.Folders | Where-Object { $_.Name -eq "Inbox" }
$Mail = $Inbox.Items[1]
# create forwarded mail
$Forward = $Mail.Forward()
$Forward.Recipients.Add($PublicFolderAddress)
$Forward.SendUsingAccount = $Account
$FW.Send()

But the assignment $Forward.SendUsingAccount = $Account fails with exception.

(Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)

  • How can I define the SMTP server for the mail to avoid sending to the POP3 server?
  • How can I keep the original sender name and address so that the mail is effectively "moved" to the public folder? The encryption shall be removed in this process.

Edit: The main objective is to decrypt the message an make it public on the Exchange server.

vba
powershell
email
outlook
asked on Stack Overflow Jun 4, 2018 by harper • edited Jun 24, 2020 by Martijn Pieters

1 Answer

0

You cannot just forward it and keep the signature intact. You can move the message to any folder using MailItem.Move().


User contributions licensed under CC BY-SA 3.0