![]() |
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
|
|||
|
|||
![]()
Hi,
I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
#2
|
|||
|
|||
![]()
You need to be checking the named MAPI properties set on the message when
you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
#3
|
|||
|
|||
![]()
Can you please give me an example.
If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
#4
|
|||
|
|||
![]()
Not in the Outlook Object Model... You can use Extended MAPI (C++ or Delphi
only) to read the following named prop {00062008-0000-0000-C000-000000000046}, 0x8581, PT_STRING8 to get the account id, then use the recently documented IOlkAccountManager interface to retrieve the corresponding account. Once you have IOlkAccount object, you can call IOlkAccount::GetProp(0x000C001F) to read the e-mail address. If the property is not set on the message, that means the default accout is being used, so you can call IMAPISession::QueryIdentity to retrieve the current user's name and address. plug You can also use Redemption (url below) to read the account used to send the message: 'save it first to make sure MAPI can see the latest changes MailItem.Save 'reopen the given message (MailItem) as Redemption.RDOMail set Session = CreateObject("Redemption.RDOSession") Session.MAPIOBJECT = Application.Session.MAPIOBJECT set Msg = Session.GetMessageFromID(MailItem.EntryID) 'get the account info set Account = Msg.Account if (Account is Nothing) Then 'default account MsgBox Session.CurrentUser.SMTPAddress Else if Account.AccountType = 0 Then 'atPOP3 MsgBox Account.SMTPAddress end if End If /plug Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Can you please give me an example. If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
#5
|
|||
|
|||
![]()
Thanks a lot!
"Dmitry Streblechenko" wrote: Not in the Outlook Object Model... You can use Extended MAPI (C++ or Delphi only) to read the following named prop {00062008-0000-0000-C000-000000000046}, 0x8581, PT_STRING8 to get the account id, then use the recently documented IOlkAccountManager interface to retrieve the corresponding account. Once you have IOlkAccount object, you can call IOlkAccount::GetProp(0x000C001F) to read the e-mail address. If the property is not set on the message, that means the default accout is being used, so you can call IMAPISession::QueryIdentity to retrieve the current user's name and address. plug You can also use Redemption (url below) to read the account used to send the message: 'save it first to make sure MAPI can see the latest changes MailItem.Save 'reopen the given message (MailItem) as Redemption.RDOMail set Session = CreateObject("Redemption.RDOSession") Session.MAPIOBJECT = Application.Session.MAPIOBJECT set Msg = Session.GetMessageFromID(MailItem.EntryID) 'get the account info set Account = Msg.Account if (Account is Nothing) Then 'default account MsgBox Session.CurrentUser.SMTPAddress Else if Account.AccountType = 0 Then 'atPOP3 MsgBox Account.SMTPAddress end if End If /plug Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Can you please give me an example. If I could get the final eMail-Adress which will be used this would be even better. "Dmitry Streblechenko" wrote: You need to be checking the named MAPI properties set on the message when you select an account rather than check the state of the dropdown control on the inspector. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "DanielH" wrote in message ... Hi, I am using the following code in my ItemSend-notification to get the name of the account from which the current eMail will be sent [C#-Plugin]: void applicationObject_ItemSend(object oItem, ref bool Cancel) { Outlook.MailItem Item = oItem as Outlook.MailItem; string senderAddress = ""; Outlook.Inspector OLI = Item.GetInspector; CommandBars CBs; CommandBarPopup CBP; object ID_ACCOUNTS = 31224; if(OLI==null) return; CBs = OLI.CommandBars; object type = 10; object visible = 1; CBP = CBs.FindControl(type, ID_ACCOUNTS, null, visible) as CommandBarPopup; if(CBP == null) return; object index = 1; CommandBarControl MC = CBP.Controls[index]; int pos = MC.Caption.IndexOf(' '); if(pos = 0) senderAddress = MC.Caption.Substring(0, pos); else senderAddress = MC.Caption; Actually, this kind of works, but I am always one iteration behind. Imagine, I change from default to account2, then click Send, I will receive Default. Changing it again to account2, I will get account2. Anyone knows this problem? Any workaround? Kind regards, Daniel |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Windows form in Inspector | Rog | Add-ins for Outlook | 1 | March 17th 06 03:55 PM |
Transparent Inspector images | Rog | Add-ins for Outlook | 7 | March 15th 06 10:52 PM |
Right Click on Inspector Window header | jim | Add-ins for Outlook | 1 | February 18th 06 12:09 AM |
Help! Inspector.Close is fired before Inspector.Activate handler finishes | Sergey Anchipolevsky | Add-ins for Outlook | 8 | February 9th 06 10:51 AM |
how to add commandbarbutton to inspector window | Ram | Outlook and VBA | 0 | January 19th 06 07:07 AM |