![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
I want determine the account an email was received so I can move it to a
folder for that account. (Yes I know that rules will do this for me but my rules will not work unless I am connected to the exchange server, even though they are client side rules). Is there a way to determine the account in code? |
#2
|
|||
|
|||
![]()
The receiving email address is not exposed in the Outlook object model, it's
available in lower level API's such as CDO 1.21 or Extended MAPI or Redemption as PR_RCVD_REPRESENTING_EMAIL_ADDRESS at property tag 0x0078001E. If Exchange is the receiving account the result would be an Exchange DN, not an SMTP address though. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sean Farrar (Intechrity)" Sean Farrar wrote in message ... I want determine the account an email was received so I can move it to a folder for that account. (Yes I know that rules will do this for me but my rules will not work unless I am connected to the exchange server, even though they are client side rules). Is there a way to determine the account in code? |
#3
|
|||
|
|||
![]()
I have five accounts (1 Exchange and 4 SMTP).
"Ken Slovak - [MVP - Outlook]" wrote: The receiving email address is not exposed in the Outlook object model, it's available in lower level API's such as CDO 1.21 or Extended MAPI or Redemption as PR_RCVD_REPRESENTING_EMAIL_ADDRESS at property tag 0x0078001E. If Exchange is the receiving account the result would be an Exchange DN, not an SMTP address though. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sean Farrar (Intechrity)" Sean Farrar wrote in message ... I want determine the account an email was received so I can move it to a folder for that account. (Yes I know that rules will do this for me but my rules will not work unless I am connected to the exchange server, even though they are client side rules). Is there a way to determine the account in code? |
#4
|
|||
|
|||
![]()
I don't care if you have 100 email accounts, you still would have to read
that MAPI property and if you get an Exchange DN and want an SMTP address you'd have to convert it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sean Farrar (Intechrity)" wrote in message ... I have five accounts (1 Exchange and 4 SMTP). |
#5
|
|||
|
|||
![]()
So how do I read that property and convert it?
"Ken Slovak - [MVP - Outlook]" wrote: I don't care if you have 100 email accounts, you still would have to read that MAPI property and if you get an Exchange DN and want an SMTP address you'd have to convert it. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sean Farrar (Intechrity)" wrote in message ... I have five accounts (1 Exchange and 4 SMTP). |
#6
|
|||
|
|||
![]()
What language are you working with and what development platform?
You can use CDO 1.21 or Extended MAPI or a MAPI wrapper such as Redemption for this. CDO is not supported for .NET code and is an optional installation, Extended MAPI is not supported for .NET code and is C++ or Delphi only, Redemption and other MAPI wrappers are usable in COM and .NET languages. Here's a CDO example using VBA code: Function GetAccount(sEntryID As String) As String ' EntryID of the email to check Dim oSession As MAPI.Session Dim oRecip As MAPI.Recipient Dim oAE As MAPI.AddressEntry Dim oMessage As MAPI.Message Dim oDummy As MAPI.Message Dim sEmail As String Const PR_RCVD_REPRESENTING_EMAIL_ADDRESS _ As Long = &H78001E Const PR_EMAIL As Long = &H3003001E 'usable with piggy-back logon only when Outlook is already running Set oSession = New MAPI.Session oSession.Logon "", "", False, False Set oMessage = oSession.GetMessage(sEntryID) sEmail = oMessage.Fields(PR_RCVD_REPRESENTING_EMAIL_ADDRESS ) If (Instr(1, sEmail, "/cn", vbTextCompare) 0) Then ' EX address Set oDummy = oSession.Inbox.Messages.Add("Test subject", _ "Test body") Set oRecip = oDummy.Recipients.Add("", sEmail) oRecip.Resolve If (oDummy.Recipients.Resolved) Then Set oAE = oRecip.AddressEntry GetAccount = oAE.Fields(PR_EMAIL) ' in cached EX mode you do not get PR_EMAIL ' in that case you must read PR_EMS_AB_PROXY_ADDRESSES ' at &H800F101E, a multivalued string property. Iterate the array ' that is returned looking for the one that starts with "SMTP:" - the ' default SMTP address for that EX recipient. Else GetAccount = "" 'failure End If Else GetAccount = sEmail End If oSession.Logoff ' now set all objects = Nothing End Function Of course the code would be somewhat different for Redemption or Extended MAPI. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Sean Farrar (Intechrity)" wrote in message ... So how do I read that property and convert it? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2002--How do I change account which email account is active? | Dana | Outlook - General Queries | 0 | December 26th 06 04:19 PM |
determining Senders smtp address | Paul Young | Outlook and VBA | 4 | November 2nd 06 05:18 PM |
Determining public folder server from Windows Outlook | Tim Murray | Outlook - Calandaring | 18 | September 20th 06 01:57 AM |
Determining When and Who schedules an appointment for a shared cal | K. Diotte | Outlook - Calandaring | 0 | September 11th 06 03:23 PM |
Determining account being used | Scott | Outlook and VBA | 2 | January 25th 06 04:39 PM |