If Item.senderemailaddress Problem

Status
Not open for further replies.
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

Jeff C

Live Well .. Be Happy In All You Do
 
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.

Sue Mosher

"Jeff C" <JeffC> wrote in message

news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> 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
 

Jeff C

Live Well .. Be Happy In All You Do

"Sue Mosher [MVP]" wrote:


> 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.


> > Sue Mosher
> > >

> "Jeff C" <JeffC> wrote in message
> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> >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


> .
>
 

Jeff C

Live Well .. Be Happy In All You Do

"Sue Mosher [MVP]" wrote:


> 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



> > Sue Mosher
> > >

> "Jeff C" <JeffC> wrote in message
> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> >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


> .
>
 
In Outlook 2007, what value do you see for SentOnBehalfOf?

Sue Mosher

"Jeff C" <JeffC> wrote in message

news:82C2B0EC-DC1A-498F-BC88-5758FC24854F@microsoft.com...

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

> "Sue Mosher [MVP]" wrote:
>
> > 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.
>

>> "Jeff C" <JeffC> wrote in message
> > news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> > >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
 

Jeff C

Live Well .. Be Happy In All You Do

"Sue Mosher [MVP]" wrote:


> 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


> > Sue Mosher
> > >

> "Jeff C" <JeffC> wrote in message
> news:82C2B0EC-DC1A-498F-BC88-5758FC24854F@microsoft.com...
> > This suggestion works in Outlook 2003 but not in Outlook 2007, what
> > changes
> > need to be made?
> > "Sue Mosher [MVP]" wrote:
> >
> >> 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.
> >
> >> "Jeff C" <JeffC> wrote in message
> >> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> >> >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


> .
>
 
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

"Jeff C" <JeffC> wrote in message

news:93A303BC-D658-4809-8554-1D55DD3F3E20@microsoft.com...

> "Sue Mosher [MVP]" wrote:
>
> > 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.



>

>> "Jeff C" <JeffC> wrote in message
> > news:82C2B0EC-DC1A-498F-BC88-5758FC24854F@microsoft.com...
> >> > This suggestion works in Outlook 2003 but not in Outlook 2007, what
> > > changes
> > > need to be made?
> >> > "Sue Mosher [MVP]" wrote:
> >> >> 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.
> > >
>> >> "Jeff C" <JeffC> wrote in message
> > >> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> > >> >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
 

Jeff C

Live Well .. Be Happy In All You Do

"Sue Mosher [MVP]" wrote:


> 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.


> Sue Mosher
> > >

> "Jeff C" <JeffC> wrote in message
> news:82C2B0EC-DC1A-498F-BC88-5758FC24854F@microsoft.com...
> > This suggestion works in Outlook 2003 but not in Outlook 2007, what
> > changes
> > need to be made?
> > "Sue Mosher [MVP]" wrote:
> >
> >> 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.
> >
> >> "Jeff C" <JeffC> wrote in message
> >> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> >> >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


> .
>
 
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.

Sue Mosher

"Jeff C" <JeffC> wrote in message

news:D4A48193-A412-4C80-912C-3242266CCD20@microsoft.com...
> 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.
>
>

>> "Jeff C" <JeffC> wrote in message
> > news:82C2B0EC-DC1A-498F-BC88-5758FC24854F@microsoft.com...
> >> > This suggestion works in Outlook 2003 but not in Outlook 2007, what
> > > changes
> > > need to be made?
> >> > "Sue Mosher [MVP]" wrote:
> >> >> 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.
> > >
>> >> "Jeff C" <JeffC> wrote in message
> > >> news:C796BE86-B833-4BE0-8EF9-D7541F6630E9@microsoft.com...
> > >> >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

>

>
>> .
> >
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Outlook365 search item listed as "potential matches" can't be opened Using Outlook 0
H Outlook 365 O365 outlook calendar item editing Using Outlook 1
P "Item could not be moved" message occurs frequently for IMAP inbox, Office 365 Using Outlook 0
V How to add 'Previous Item' and 'Next Item' to the Quick Access Toolbar Using Outlook 1
O In Agenda-view - How to copy an existing item months ahead or back? Using Outlook 0
S Outlook 2016 dont delete inbox item Using Outlook 0
talla Can't open Outlook Item. Using Outlook 0
N Item cannot be saved because it was modified by another user or window, and, Item could not be moved... Using Outlook 0
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
S Command Button_Click action on Item/Reminder Outlook VBA and Custom Forms 3
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
C Copy Move item won't work Outlook VBA and Custom Forms 2
T Pictures degrade each time an Outlook item is edited and re-saved Using Outlook 1
B Change row background color of selected item Using Outlook 1
P Outlook 2013 "Item could not be moved - still an issue for Outlook 2013 Using Outlook 0
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
geoffnoakes Find Contacts with UDFs "in this item" Using Outlook 1
T "cannot find the calendar folder for this item" - calendar items stuck in outbox Using Outlook 0
GregS Many Sent Item folders Using Outlook 3
B Select / activate first email item in the searched query Using Outlook 1
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
N "Discussion" item Using Outlook 3
T outlook.com opens with "item not found" Using Outlook 1
Peter H Williams How to Move Mail item after processing Outlook VBA and Custom Forms 5
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
M Shortcut to another outlook item Using Outlook 0
M Item edits doesn't always sync Using Outlook 11
Cdub27 Your changes to this item couldn't be saved because Server Denied Operation (HTTP 403 Forbidden) Using Outlook 1
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
P Replying to calendar item using VBA Outlook VBA and Custom Forms 4
G Outlook item link Using Outlook 0
Q VBA Script to move item in secondary mailbox Outlook VBA and Custom Forms 2
D Save Sent Item to Using Outlook 0
T outlook 2010 mail item count doesnt match display Outlook VBA and Custom Forms 3
Jeanne Goodman Delete Calendar Item Bypassing Deleted Items folder Outlook VBA and Custom Forms 2
Diane Poremsky Display the Created Date field of any Outlook item Using Outlook 0
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0
Z Item.Recipients for Task Assignment on Send Outlook VBA and Custom Forms 10
M How does Outlook determine item numbers in a folder? Outlook VBA and Custom Forms 3
J "This item has been changed still want to delete it" message Using Outlook 3
oliv- HIDE ITEM Outlook VBA and Custom Forms 3
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
T Create new item in public folder using VBscript Outlook VBA and Custom Forms 1
D Shared Mailbox with mail item marked as "private" Using Outlook 0
Diane Poremsky Change Item Count on All Folders in a Data File Using Outlook 0
M Recurring icon for custom form task item Outlook VBA and Custom Forms 6
N Adding Appointment Item in Outlook to Shared Calendar Folder Outlook VBA and Custom Forms 7
V Locate item Account Outlook VBA and Custom Forms 7
JohnP Shared Mailboxes "Save Sent Item" Using Outlook 2

Similar threads

Back
Top