Sending mail from another postbox in VBA??

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hi,

in my outlook configuration there is a second postbox "username2"
where i have full access. Now I want to send mails where the sender is
this second identity and not my own name "MyUsername". In the normal
Outlook send dialog there is a button "From", so that i can choose the
sender ... but how can i do this in VBA?
I programmed it in Excel VBA like this, it works fine, but only
(automatically) with "MyUsername" as sender:

Dim ol, MyMail As Object
Set ol = CreateObject("Outlook.Application")
Set MyMail = ol.CreateItem(0)
MyMail.Subject = "Hello friends"
MyMail.To = "(e-mail address removed)"
MyMail.Body = "Hello again!"
MyMail.Send

What must i change so that the mail sender is "username2"?? I read the
docu, but i find nothing. I tried something with namespace but without
success.

Thanx for any hints and code examples!

Greetings from Frank
 
It might be overkill but this can be done using CDO, inside an outlook
macro - perhaps someone in here know a better way.


Regards.

Lars Roland
 
You can't do that using the Outlook object model. You would have to use
Extended MAPI (C++ or Delphi code only), CDO 1.21 (optional installation
with Outlook 2000 and later and subject to the security prompts) or
Redemption (3rd party library at www.dimastr.com/redemption) to do that.

See the code example for sending with a different From address at
www.cdolive.com/cdo5.htm for a CDO 1.21 way of doing it.
 
That sends with an On Behalf Of piece in the message, which is a different
thing.




Gerrit Bigalski said:
[about changing the sender ("From") to another account]
You can't do that using the Outlook object model.

What about SentOnBehalfOfName?

Gerrit
 
[about SentOnBehalfOfName in respect to changing the sender ("From")
to another account]
That sends with an On Behalf Of piece in the message, which is a different
thing.

This is not quite how I experienced it to work: If you set it to an
e-mail-address, this address is used as the "From"-header, and,
depending on something I haven't figured out yet, sets the
"Sender"-header to the users standard-address or not. If there is a
"Sender"-header, then Outlook shows you the "On Behalf Of" piece in
the subject.

Gerrit

Sent via Google, because your answer didn't show up on my usual
newsserver.
 
That depends on how the mailbox is set up on the Exchange server. A true
"From" using a user-entered From address only occurs when the user has
SendAs permissions for that mailbox.




Gerrit Bigalski said:
"Ken Slovak - [MVP - Outlook]" <[email protected]> wrote in message
[about SentOnBehalfOfName in respect to changing the sender ("From")
to another account]
That sends with an On Behalf Of piece in the message, which is a different
thing.

This is not quite how I experienced it to work: If you set it to an
e-mail-address, this address is used as the "From"-header, and,
depending on something I haven't figured out yet, sets the
"Sender"-header to the users standard-address or not. If there is a
"Sender"-header, then Outlook shows you the "On Behalf Of" piece in
the subject.

Gerrit

Sent via Google, because your answer didn't show up on my usual
newsserver.
 
Hi Ken
Sorry to pick up this conversation half way through, but I
have a small question in regards to this. I have some
users set up on exchange 2000 to access a shared mailbox
with SendAs permissions. When a new mail is created from
the inbox of the shared mailbox the From field is empty.
Is there a way to set this to the address of the mailbox
whose inbox you're in, or a way to set this always to the
mailbox's address as default?

Many thanks,
Amanda
-----Original Message-----
That depends on how the mailbox is set up on the Exchange server. A true
"From" using a user-entered From address only occurs when the user has
SendAs permissions for that mailbox.




Gerrit Bigalski said:
"Ken Slovak - [MVP - Outlook]" <[email protected]>
wrote in message
[about SentOnBehalfOfName in respect to changing the sender ("From")
to another account]
That sends with an On Behalf Of piece in the message,
which is a
different
This is not quite how I experienced it to work: If you set it to an
e-mail-address, this address is used as the "From"- header, and,
depending on something I haven't figured out yet, sets the
"Sender"-header to the users standard-address or not. If there is a
"Sender"-header, then Outlook shows you the "On Behalf Of" piece in
the subject.

Gerrit

Sent via Google, because your answer didn't show up on my usual
newsserver.


.
 
Yes, that can be done but not with the Outlook object model. You would have
to use CDO 1.21 (optional installation for Outlook 2000 and later) or
Extended MAPI (C++ or Delphi code only) or Redemption (3rd party library at
www.dimastr.com/redemption).

There is a code example using CDO 1.21 at
http://www.cdolive.com/cdo5.htm#MessageOriginator that you can look at to
see how it's done and I think that the Redemption Web site also has a code
sample for this too.
 
Back
Top