Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Mailitem send as

Status
Not open for further replies.

mattKnight

Programmer
May 10, 2002
6,225
GB
Hi

I have the following problem (currently running OL 2007 on XP, but company wide mixture of OL 2003 / 2007 on XP) I've not tried the code on a OL 2003 machine.

We have a group mailbox that we use for support emails. When we reply to an email in this box, it is tagged as being sent by the support user. We have soem software that will add a signature to any emails. We wish to use individual personalised signatures for replies from this support user. We have a number of users who can do this

The whole scheme works if I manually type the users address in the From field of the email.

If I run the following macro
Code:
Sub NewSupportEmail()
 Dim myFolder As Folder
 Dim myItem As MailItem
 
 Set myFolder = Session.GetDefaultFolder(olFolderInbox)
 Set myItem = myFolder.Items.Add("IPM.Note")

 myItem.SentOnBehalfOfName = "Matt Knight Support"
 myItem.Recipients.ResolveAll
 myItem.Display
End Sub

A standard email form is generated and the From field populated ok. The email gets sent and the correct personalised signature is applied.

However, if I open a received email in the support box and click reply and run the follwoing m,acro

Code:
Sub Personalise()
Dim MyMailitem As MailItem
If ActiveInspector.CurrentItem.Class = olMail Then
Set MyMailitem = ActiveInspector.CurrentItem

 If MyMailitem.SentOnBehalfOfName = "Support" Then
   'Check that the email we are changing is originally sent from the support box
  MyMailitem.SentOnBehalfOfName = "Matt Knight Support"     
   'Change teh from details
  MyMailitem.Recipients.ResolveAll
   'resolve address
 End If

End If

End Sub

This changes the from address in the reply and resolves it correctly. When the reply is sent, the sent items folder shows it sent as "Matt Knight Support" but when you click on the From address in the opened mail from the send items folder, the address book shows the "Support" address. The signature is the generic support one. The signature software sees the sent reply as being sent from the "Support" address.

If I manually enter the "Matt Knight Support" address into a reply from teh support box, everything works as expected, so I can't see this being anything other than my poor VBA skills...

My guess is that the Sendonbehalfof doesn't do what I think it does (i.e. sends on behalf of not SendAs) but why does it work if when a new Email is generated (call to NewSupportEmail())

Any clues?

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top