If Item.senderemailaddress Problem

J

Jeff C

I have been trying alternatives to the code below with no luck at all. The
code works fine but am trying to add the if condition to only BCC the strBCC
if I am using my Send As account in the exchange. Can anyone point me in the
right direction? I think I am just missing something here. Thanks


Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next

#### USER OPTIONS ####
address for Bcc -- must be SMTP address or
resolvable
to a name in the address book

strBcc = "MySendAsMailAddress"


If Item.SenderEmailAddress =
"mysendasmailaddress.com" Then

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc
recipient. " & _
"Do you want still to send the
message?"
res = MsgBox(strMsg, vbYesNo +
vbDefaultButton1, _
"Could Not Resolve Bcc Recipient")
If res = vbNo Then
Cancel = True
End If
End If
End If

Set objRecip = Nothing
End Sub
 
S

Sue Mosher [MVP]

Outlook version? By "Send As account," do you mean that you're sending as
another Exchange user? If so, try looking at the value of the SentOnBehalfOf
property.
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


Sue Mosher said:
Outlook version? By "Send As account," do you mean that you're sending as
another Exchange user? If so, try looking at the value of the SentOnBehalfOf
property.

I am using Outlook 2003 with all the service pack updates in a corporate
exchange server. Thank you so much - your suggestion works great!

This solves many issues with organizing SendAs mail from a generic mailbox.
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


Sue Mosher said:
Outlook version? By "Send As account," do you mean that you're sending as
another Exchange user? If so, try looking at the value of the SentOnBehalfOf
property.

This suggestion works in Outlook 2003 but not in Outlook 2007, what changes
need to be made?

Thank you
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


Sue Mosher said:
In Outlook 2007, what value do you see for SentOnBehalfOf?

With the code being in "thisoutlooksession" module, I can't figure out how
to view that value. Been searching for differences on this between the two
versions, Outlook 2003 vs 2007 and can't find a reference. Any more
assistance would be appreciated.

Thank you
 
S

Sue Mosher [MVP]

Check the value of Item.SentOnBehalfOfName (sorry, I got the property name
wrong earlier, but you could have looked it up in the object browser) using
any of the standard VBA techniques that you'd use to check the value of an
expression: Set a watch variable, use Debug.Print or MsgBox, use a
breakpoint, etc.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


Sue Mosher said:
In Outlook 2007, what value do you see for SentOnBehalfOf?

Well, the code using

If Item.SentOnBehalfOfName="DisplayName" then

Works perfectly in Outlook 2003. I've tries it every which way in 2007
including using the Alias, and the actual email address without any luck.

Any other ideas? Than you.
 
S

Sue Mosher [MVP]

Still waiting for an answer to my question: If the value of
SentOnBehalfOfName isn't "DisplayName," then what is it? That may indicate
your next step.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top