Change identity or "from" field if a rule matches

Status
Not open for further replies.

Benedict

Member
Outlook version
Outlook 2013 64 bit
Email Account
IMAP
Hi folks!

I got a Problem. I have one account with several aliases and everytime i get a mail to ***@my-domain1 i have to select my identity "***@my-domain1" and if the mail goes to my-domain2 i have to select my-domain2 at the "FROM field". If i don`t do it, the default identity is used and sometimes i forget to select the right identity and this is kind of bad for me.

I would like to have this automatically. So if i receive a mail with ***@my-domain3 and click on "answer" i want ***@my-domain3 to be set in the "FROM" field.

Is there any solution for it?

I thought about defining a rule: "if i received a mail with ***@my-domain3" execute a script which sets the FROM field with the value "***@my-domain3" if i answer this email.

But i dont know much about programming in general, so can somebody tell me if this is possible and how this script would look like? Or is there another/better solution or maybe a plugin?

Many thanks for your answers!!
 
For setting the sender address try the mentioned macro. If the emails are forwarded to that one account, see if you can find the original address in the PR_TRANSPORT_MESSAGE_HEADERS_W property. For this part you could use a run-a-script rule that looks for certain words in the message header.
 
Hello! Thanks for your answers! I tested the macro, but it doesnt work so far :-( Maybe it does work for accounts, but not for identities??
 
You don't need a script for that part. Create a rule that looks for the address, where the email was actually sent to, in the message header.
 
Ok i got that, but i cannot edit an action that says, that the mail should be sent with my second identity.
 
Ok, if the rule works, use it to assign a certain category. Then modify the given script to set the SentOnBehalfOfName property, that is if category "a" is assigned, send as "*@domain1", if "b" is assigned, send as "*@domain2".

If you don't have an Exchange account, setting the SentOnBehalfOfName property doesn't have the wanted effect. In that case you need to add an account for each address, or identity as you call it.
 
Thanks @Michael Bauer for your help, but i guess i expressed myself in a wrong way. With "Identity" i mean an "FROM" adress that i created manually in the FROM field. I just got one IMAP account which could server-sided a few aliases so that the mails get forwarded to the main adress which is assigned to that one account.

So the script has to chosse an specific address which i created in the from field.
 
You need to understand how Outlook works: It can send only via accounts, each account can have one address. What you manually enter in the From textbox is an address that's put by Outlook into the SentOnBehalfOfName property of the email. It'll still send using your account.

If you had an Exchange account, and if you had the permission to send on behalf of that name, then the receiver of your email would see the sender as you want it. Without an Exchange account the receiver will see the sender information as:
"Your account name/email address" on behalf of "the address entered in the From box"

So, as you don't have an Exchange account, create one imap account in Outlook for each alias you have, and use the script to set the SendUsingAccount property.
 
Ahh OK, now i get it. I created a script and it works :) Now i have to integrate it in the answer button (or create a new one?) So if i click on "answer" the script i wrote has to be executed. Maybe you can give me a hint how i have to do that?
 
And another Question: Is there a function where i can check to which identity the mail was sent? So that i can say "if the mail was sent to blip@identity1.de then answer with blip@ identity1 else take default?"
 
1. Easiest for you would be to add a button to the QAT that calls the macro. Use that one instead of Outlook's Reply button.

If you want to put some more effort into it yourself, see the SelectionChange event. When that event fires, check if SelectionCount is 1. If so, set a variable, declared with WithEvents, on the one selected item so you can get events of that item. Here catch the Reply event. It passes a reference on the reply item, which needs be used in your macro.

2. If that address is available, then you'll find it the message header. See the example for "PropertyAccessor" in the VBA help file.
 
Michael, thanks for your help and your patience! Might i ask if you could provide me a code snippet for a better understanding? I got to say, that i am not a programming expert and my code doesn`t work :-(
 
Did you look at the mentioned example in the VBA help file? Show your code, please.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Use Macro to change account settings Outlook VBA and Custom Forms 0
D Unable to change AppointmentItem.Start property Outlook VBA and Custom Forms 3
sjmo2 Change subject for new e-mails only. Outlook VBA and Custom Forms 2
Horsepower Contact phone numbers randomly change Using Outlook 0
P Outlook 2016 Change Paste Special Default Format Using Outlook 8
whizzard Change FROM address based on TO or CC address Outlook VBA and Custom Forms 8
S Outlook 365 Can I change the possible range of highlighting colours when writing an Outlook email? Using Outlook 1
V Can one change the formatting of email title blocks? Using Outlook 0
S Unable to change Message Class Outlook VBA and Custom Forms 0
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
J VBA Cannot programmatically input or change Value for User Defined field Using Outlook 1
C Outlook 365 Can you change the follow up colour? Using Outlook 1
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
E Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
O What would be the recommended way to change an email address (family member)? Using Outlook 0
S Change "This Week" flag start date behavior Using Outlook 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
D Change Microsoft Account password - what to do to update on all devices Using Outlook 4
S Outlook 2016 Change how Outlook shows me contacts in emails Using Outlook 0
Witzker HowTo Change message Class of contact form Outlook VBA and Custom Forms 0
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
Witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R How to Change Margins In Google Docs...? Using Outlook 0
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
Z See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 90
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0

Similar threads

Back
Top