This topic contains 5 replies, has 2 voices, and was last updated by
January 28, 2016 at 7:28 am #34447
i've done a lot of googling this morning, and have found using the outlook.application method to do this, however, this won't work when running powershell using authorized accounts as they do not have mailboxes.
what i need is a way to send these when the account logged into powershell does not have a mailbox.
i've had to do appointments in the same fashion, but in that case i wound up running a seperate script in a called window asking for different credentials. as this is going into a gui tool, this isn't optimal.
the only thing that is coming to mind would be to run a script-block as another user, but, not really sure how i could accomplish that
January 28, 2016 at 7:33 am #34449
The voting buttons are an Outlook-specific piece of functionality. I imagine Outlook encodes something into the message to trigger that display, so all I can think of is to send one of those messages to a Gmail account, try to look at the raw message, and see what Outlook's embedding in there. Then you could try and duplicate that using Send-MailMessage.
This (https://support.microsoft.com/en-us/kb/290809) suggests Microsoft is using TNEF-encoding, which is super-not-common. It's also based on RTF, not HTML, which means actually constructing the message manually is going to be a PITA.
Further, from what I'm reading, the Voting functionality only works if the sender has an actual mailbox on the server. So if you use Send-MailMessage, you'd need to make sure the Reply-To and Send-As are set to an actual mailbox. That also means your Exchange server is going to have to allow relaying, which it probably doesn't.
You've got a lot of hurdles in front of you on this one, not because of PowerShell, but because of the way this feature works. Good luck.
January 28, 2016 at 8:09 am #34452
i did find the following code snippets to do this utilizing the outlook.application method: $olComObject = new-object -comobject outlook.application
$NewMail = $olComObject .CreateItem(0)
$NewMail.Subject = "Testing Voting Options"
$HTMLBody = "Please use the attached voting buttons in this email to select the best scripting language!"
$NewMail.HTMLBody = $HTMLBody
$NewMail.To = "firstname.lastname@example.org"
the issue is the gui will have to be run as an account without a mailbox.
would you have any quick pointers to executing a code-block fully as another user?
January 28, 2016 at 9:17 am #34460
Do you know their password, and are you willing to have it stored in plain text?
January 28, 2016 at 9:25 am #34462
well, i can add userid/pw masked text boxes in the gui and have the users input that value
thats where i was starting, but, couldn't wrap my head around calling just that specific code to be fully run as another user
January 28, 2016 at 9:33 am #34463
OK, well in that case you probably do it. Just use Get-Credential to prompt for the credential, and use Start-Job to pass the script block and the credential. Or, put the necessary code in a separate script, and run it with Start-Process, which also accepts a credential.
The topic ‘send-mail message with vote buttons’ is closed to new replies.