PDA

View Full Version : Change Sender Name Under VBA Control



MWE
01-03-2016, 08:34 AM
I am (still) running ol2003. I wish to change the sender name on an email as it is sent out. I have explored several approaches

manually changing the user name in the profile set up. That works but takes time and requires that you remember to change it back later. Also, I want the approach to work within VBA procedures so manual fiddling will not work and I have not found a way to change the user name for a profile using VBA.

adding another account to a given profile which is "send only" with the required user name. That works but only for a single user name
I thought it would be simple to write a VBA macro that would do this. I assumed that the relevant attribute for an ol mailitem would be SenderName and I would simply change SenderName and send the email. But SenderName is a read only attribute.
So I tried using SentOnBehalfOf which apparently requires that the provided string refers to a contact. Which means that a bogus contact is required for each "other" Sender Name. That approach works and the recipient sees the Alt Name as the sender in his/her InBox (which is what I want) but requires a bogus contact be created for each other sender, is still a bit more work than it should be and not quite as clean as I would like
So I switched to Redemption; SenderName is not read only for an RDOmailitem. The code runs fine and SenderName is what I want when the RDOmailitem is sent, but when the email arrives, the Sender is the original user name. So maybe SenderName is not the right attribute??


Any suggestions?

gmayor
01-04-2016, 12:19 AM
What you ask is not possible. Outlook blocks code that attempts to access the SenderName property for security reasons. See https://msdn.microsoft.com/en-us/library/office/aa171985%28v=office.11%29.aspx?f=255&MSPPError=-2147217396

MWE
01-04-2016, 06:21 AM
What you ask is not possible. Outlook blocks code that attempts to access the SenderName property for security reasons. See https://msdn.microsoft.com/en-us/library/office/aa171985%28v=office.11%29.aspx?f=255&MSPPError=-2147217396 Thanks. I agree that Outlook blocks certain actions for security reasons but Redemption allows you to get around many of the limitations of Outlook. As mentioned above, the attribute SenderName (as part of the ol object MailItem) is read only, but SenderName as part of the corresponding Redemption object is not. You link is to Outlook and not to what Redemption can do. What might be happening is that somehow Outlook intervenes at the last moment and changes SenderName back to User Name regardless of what the user has done with Redemption. I have never seen Outlook and Redemption "fight" in the past but that could be what is happening.