0

When trying to send emails using another inbox, I change .SentOnBehalfOfName to the email I want to send from.

But then the email arrives with "MyRealName on behalf of EmailAddressIWantToSendFrom".

How do I remove MyRealName?

EDIT:

Set outlookApp = CreateObject("Outlook.Application")
Set namespace = outlookApp.GetNamespace("MAPI")
namespace.Logon
Set MyItem = outlookApp.CreateItemFromTemplate(path_to_msg_file)

...
pretend that this comment is a bunch of code that modifies the body of MyItem, mostly doing text replacements in MyItem.HTMLBody
...


Set safeItem = CreateObject("Redemption.SafeMailItem")
Set oItem = MyItem
safeItem.Item = oItem

safeItem.To = "person I want to send to"
safeItem.SentOnBehalfOfName = "desired address I want to sent from"

safeItem.Recipients.ResolveAll
safeItem.Send
DoubleBass
  • 1,143
  • 4
  • 12
  • 29
  • You could edit several email properties and even the `.From` property and set it to `vbNullString`. But in the end it all depends on the email server and how this server is setup. In most companies you cannot change, hide, or obscure the sender's email address or name. This would be some form of "identity theft" (if the real person sending the email - even if it is rightfully on behalf - would be missing). If you are interested you might want to Google "send anonymous email " and look through the results for more information. – Ralph Feb 29 '16 at 14:33
  • I tried setting `.From` to `vbNullString` and to EmailAddressIWantToSendFrom, neither worked sadly – DoubleBass Feb 29 '16 at 14:39
  • There is no From property neither in the Outlook Object Model nor in Redemption. – Dmitry Streblechenko Feb 29 '16 at 17:17

1 Answers1

1

To be able to send as that user, you need to have both send-as and receive-as rights. You'd need to connect to that user's mailbox and create the new message in the mailbox of the user you are trying to send as.

EDIT: Try something like the following:

  set rSession = CreateObject("Redemption.RDOSession")
  rSession.MAPIOBJECT = Application.Session.MAPIOBJECT
  set Store= rSession.GetSharedMailbox("some GAL name")
  set Folder = Store.GetDefaultFolder(olFolderOutbox)
  set Msg = Folder.Items.Add
  Msg.Subejct = "test"
  Msg.To = "user@domain.demo"
  Msg.Send
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • What do you mean by this exactly? I thought send-as rights were required for me to even use SendOnBehalfOf in the first place. Before that I wasn't able to send from that email at all (I'd get undeliverable error messages), but since I can send the emails now (albeit with RealName present), what more can be done? – DoubleBass Feb 29 '16 at 19:07
  • My point is that you need to also have Receive-as right and create the message in the mailbox of that user. – Dmitry Streblechenko Feb 29 '16 at 19:29
  • Is there a difference in the code to make it "create the message in the mailbox of that user"? – DoubleBass Feb 29 '16 at 19:56
  • You would need to open the mailbox of that user (RDOSesion.GetSharedMailbox), ope na folder (RDOStore.GetDefaultFolder(olFolderOutbox)), create the message (RDOFolder.Items.Add), etc. – Dmitry Streblechenko Feb 29 '16 at 21:03
  • I added some code to my OP to show how I am using it. Do I have to make any drastic changes? I am not familiar with these "RDO" variables you mention. – DoubleBass Feb 29 '16 at 21:09
  • Since you are using the SafeMialItem object, switching to RDO will be a bigger change and your code can run quite a bit slower since GetSharedMailbox can take a while to return. – Dmitry Streblechenko Feb 29 '16 at 22:33
  • How do I switch to RDO? I don't mind the speed slowdown -- I just need it to work. Is the code similar, just changing over to some RDO object? – DoubleBass Mar 01 '16 at 14:09