|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Hello again everybody,
I have a problem with CDO, I use the Addressbook method to search in the contacts, stored in outlook or exhange, to select someones, when they are selecteds I want to obtain the telephone number, when the contact is stored in outlook, no problem I know how i do, but the problem is when i select a contact from exchange.
I am a VB.NET programmer, and my project is an Add-in for Outlook.
This is the code:
SMScontactes = New Collection
' start CDO session
m_CDO.Logon("outlook", , False, False)
' show address book
CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del SMS", , , 1, "Destinatarios", , ), MAPI.Recipients)
For n = 1 To CType(CDOrecips.Count, Integer)
CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient)
strID = CType(CDOrecip.ID, String)
strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72)
strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6)
contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), Outlook.ContactItem)
If Not contacte Is Nothing Then
SMScontactes.Add(contacte)
txtPara.Text = txtPara.Text & contacte.FullName & "(" & contacte.MobileTelephoneNumber & ");"
Else
MsgBox("No es un contacto de Outlook")
End If
Next
' release objects
m_CDO.Logoff()
Thanks in advance.
Jaume F.
|
|
You'd need to use the appropriate MAPI property tag with the CDO AddressEntry.FIelds collection. See http://www.cdolive.com/cdo10.htm. I have a Redemption sample at http://www.outlookcode.com/codedetail.aspx?id=594 as well, if you want to avoid security prompts.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in message news:%23s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text] > Hello again everybody, > > I have a problem with CDO, I use the Addressbook method to search in the > contacts, stored in outlook or exhange, to select someones, when they are > selecteds I want to obtain the telephone number, when the contact is stored > in outlook, no problem I know how i do, but the problem is when i select a > contact from exchange. > > I am a VB.NET programmer, and my project is an Add-in for Outlook. > > This is the code: > > SMScontactes = New Collection > > ' start CDO session > > m_CDO.Logon("outlook", , False, False) > > > > ' show address book > > CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del > SMS", , , 1, "Destinatarios", , ), MAPI.Recipients) > > > > For n = 1 To CType(CDOrecips.Count, Integer) > > CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient) > > strID = CType(CDOrecip.ID, String) > > strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72) > > strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6) > > contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), > Outlook.ContactItem) > > If Not contacte Is Nothing Then > > SMScontactes.Add(contacte) > > txtPara.Text = txtPara.Text & contacte.FullName & "(" & > contacte.MobileTelephoneNumber & ");" > > Else > > MsgBox("No es un contacto de Outlook") > > End If > > Next > > ' release objects > > m_CDO.Logoff() > > > > Thanks in advance. > > > > > Jaume F. > >
|
|
Hello Sue,
But if I want to use the recipient object of an email or an appointment item, then the example don't run. Because the objects recipient from outlook are different to the object repient of the CDO, and the property Fields don't exists in the object recipient of outlook.
How can I resolve this ?
Thank you, for your time.
Jaume F.
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje news:eeAn$jfPGHA.3924[ at ]TK2MSFTNGP14.phx.gbl... You'd need to use the appropriate MAPI property tag with the CDO AddressEntry.FIelds collection. See http://www.cdolive.com/cdo10.htm. I have a Redemption sample at http://www.outlookcode.com/codedetail.aspx?id=594 as well, if you want to avoid security prompts.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in message news:%23s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl...
[Quoted Text] > Hello again everybody, > > I have a problem with CDO, I use the Addressbook method to search in the > contacts, stored in outlook or exhange, to select someones, when they are > selecteds I want to obtain the telephone number, when the contact is
stored > in outlook, no problem I know how i do, but the problem is when i select a > contact from exchange. > > I am a VB.NET programmer, and my project is an Add-in for Outlook. > > This is the code: > > SMScontactes = New Collection > > ' start CDO session > > m_CDO.Logon("outlook", , False, False) > > > > ' show address book > > CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del > SMS", , , 1, "Destinatarios", , ), MAPI.Recipients) > > > > For n = 1 To CType(CDOrecips.Count, Integer) > > CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient) > > strID = CType(CDOrecip.ID, String) > > strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72) > > strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6) > > contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), > Outlook.ContactItem) > > If Not contacte Is Nothing Then > > SMScontactes.Add(contacte) > > txtPara.Text = txtPara.Text & contacte.FullName & "(" & > contacte.MobileTelephoneNumber & ");" > > Else > > MsgBox("No es un contacto de Outlook") > > End If > > Next > > ' release objects > > m_CDO.Logoff() > > > > Thanks in advance. > > > > > Jaume F. > >
|
|
You still have to use CDO. You can get the item's EntryID and StoreID from Outlook and then use them with the Session.GetItem method to get the corresponding item with CDO.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in message news:%239S9URiPGHA.3896[ at ]TK2MSFTNGP15.phx.gbl...
[Quoted Text] > Hello Sue, > > But if I want to use the recipient object of an email or an appointment > item, then the example don't run. Because the objects recipient from outlook > are different to the object repient of the CDO, and the property Fields > don't exists in the object recipient of outlook.
> > "Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje > news:eeAn$jfPGHA.3924[ at ]TK2MSFTNGP14.phx.gbl... > You'd need to use the appropriate MAPI property tag with the CDO > AddressEntry.FIelds collection. See http://www.cdolive.com/cdo10.htm. I have > a Redemption sample at http://www.outlookcode.com/codedetail.aspx?id=594 as > well, if you want to avoid security prompts. > > -- > Sue Mosher, Outlook MVP > Author of Configuring Microsoft Outlook 2003 > http://www.turtleflock.com/olconfig/index.htm > and Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "David Cebrian" <david_cebrian[ at ]msn.com> wrote in message > news:%23s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl... >> Hello again everybody, >> >> I have a problem with CDO, I use the Addressbook method to search in the >> contacts, stored in outlook or exhange, to select someones, when they are >> selecteds I want to obtain the telephone number, when the contact is > stored >> in outlook, no problem I know how i do, but the problem is when i select a >> contact from exchange. >> >> I am a VB.NET programmer, and my project is an Add-in for Outlook. >> >> This is the code: >> >> SMScontactes = New Collection >> >> ' start CDO session >> >> m_CDO.Logon("outlook", , False, False) >> >> >> >> ' show address book >> >> CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del >> SMS", , , 1, "Destinatarios", , ), MAPI.Recipients) >> >> >> >> For n = 1 To CType(CDOrecips.Count, Integer) >> >> CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient) >> >> strID = CType(CDOrecip.ID, String) >> >> strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72) >> >> strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6) >> >> contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), >> Outlook.ContactItem) >> >> If Not contacte Is Nothing Then >> >> SMScontactes.Add(contacte) >> >> txtPara.Text = txtPara.Text & contacte.FullName & "(" & >> contacte.MobileTelephoneNumber & ");" >> >> Else >> >> MsgBox("No es un contacto de Outlook") >> >> End If >> >> Next >> >> ' release objects >> >> m_CDO.Logoff() >> >> >> >> Thanks in advance. >> >> >> >> >> Jaume F. >> >> > >
|
|
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in news:#s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl:
[Quoted Text] > I have a problem with CDO, [...] > > I am a VB.NET programmer, and my project is an Add-in for Outlook.
You should also know that CDO1.21 and Outlook officially won't work together:
http://support.microsoft.com/kb/813349
Also, as the problems that arise are generally threading/memory management mismatches, running this as an Outlook add-in is going to make it even more complicated to work out what's going on. Quoting from a post from an MS guy a while back:
"It's the sort of thing that'll mostly work. It'll work while you're writing it. Then it'll work while you're testing it. It'll work while your customer is evaluating it. Then as soon as the customer deploys it - BAM! That's when it'll decide to start having problems. And Microsoft ain't gonna help you with it, since we told you not to do it in the first place. :)"
So you might get away with this, but I wouldn't want to rely on it.
-- dan
|
|
Exactly. That's why I'd use Redemption instead if I were doing a .NET project.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"Dan Mitchell" <djmitchella[ at ]yahoo.com> wrote in message news:Xns977A743773A87djmitchellayahoocom[ at ]207.46.248.16...
[Quoted Text] > "David Cebrian" <david_cebrian[ at ]msn.com> wrote in > news:#s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl: >> I have a problem with CDO, [...] >> >> I am a VB.NET programmer, and my project is an Add-in for Outlook. > > You should also know that CDO1.21 and Outlook officially won't work > together: > > http://support.microsoft.com/kb/813349> > Also, as the problems that arise are generally threading/memory > management mismatches, running this as an Outlook add-in is going to > make it even more complicated to work out what's going on. Quoting from > a post from an MS guy a while back: > > "It's the sort of thing that'll mostly work. It'll work while you're > writing it. Then it'll work while you're testing it. It'll work while > your customer is evaluating it. Then as soon as the customer deploys it > - BAM! That's when it'll decide to start having problems. And Microsoft > ain't gonna help you with it, since we told you not to do it in the > first place. :)" > > So you might get away with this, but I wouldn't want to rely on it. > > -- dan
|
|
Dan Mitchell <djmitchella[ at ]yahoo.com> wrote in news:Xns977A743773A87djmitchellayahoocom[ at ]207.46.248.16:
[Quoted Text] > You should also know that CDO1.21 and Outlook officially won't work > together:
Significant correction: I meant to say "CDO1.21 and .Net officially won't work together", not CDO1.21 and Outlook. Those are fine. Sorry for any confusion. > http://support.microsoft.com/kb/813349
-- dan
|
|
Thank you very much!!!
Where can i obtain more information about Redemtion? And how can i include this dll in my projects?
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje news:exrmdYiPGHA.3976[ at ]TK2MSFTNGP10.phx.gbl... You still have to use CDO. You can get the item's EntryID and StoreID from Outlook and then use them with the Session.GetItem method to get the corresponding item with CDO.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in message news:%239S9URiPGHA.3896[ at ]TK2MSFTNGP15.phx.gbl...
[Quoted Text] > Hello Sue, > > But if I want to use the recipient object of an email or an appointment > item, then the example don't run. Because the objects recipient from
outlook > are different to the object repient of the CDO, and the property Fields > don't exists in the object recipient of outlook.
> > "Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje > news:eeAn$jfPGHA.3924[ at ]TK2MSFTNGP14.phx.gbl... > You'd need to use the appropriate MAPI property tag with the CDO > AddressEntry.FIelds collection. See http://www.cdolive.com/cdo10.htm. I have > a Redemption sample at http://www.outlookcode.com/codedetail.aspx?id=594 as > well, if you want to avoid security prompts. > > -- > Sue Mosher, Outlook MVP > Author of Configuring Microsoft Outlook 2003 > http://www.turtleflock.com/olconfig/index.htm > and Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "David Cebrian" <david_cebrian[ at ]msn.com> wrote in message > news:%23s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl... >> Hello again everybody, >> >> I have a problem with CDO, I use the Addressbook method to search in the >> contacts, stored in outlook or exhange, to select someones, when they are >> selecteds I want to obtain the telephone number, when the contact is > stored >> in outlook, no problem I know how i do, but the problem is when i select a >> contact from exchange. >> >> I am a VB.NET programmer, and my project is an Add-in for Outlook. >> >> This is the code: >> >> SMScontactes = New Collection >> >> ' start CDO session >> >> m_CDO.Logon("outlook", , False, False) >> >> >> >> ' show address book >> >> CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del >> SMS", , , 1, "Destinatarios", , ), MAPI.Recipients) >> >> >> >> For n = 1 To CType(CDOrecips.Count, Integer) >> >> CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient) >> >> strID = CType(CDOrecip.ID, String) >> >> strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72) >> >> strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6) >> >> contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), >> Outlook.ContactItem) >> >> If Not contacte Is Nothing Then >> >> SMScontactes.Add(contacte) >> >> txtPara.Text = txtPara.Text & contacte.FullName & "(" & >> contacte.MobileTelephoneNumber & ");" >> >> Else >> >> MsgBox("No es un contacto de Outlook") >> >> End If >> >> Next >> >> ' release objects >> >> m_CDO.Logoff() >> >> >> >> Thanks in advance. >> >> >> >> >> Jaume F. >> >> > >
|
|
See http://www.dimastr.com/redemption/. It comes as a redistributable version you can include with your project's setup files.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx
"David Cebrian" <david_cebrian[ at ]msn.com> wrote in message news:OlDFBjsPGHA.3192[ at ]TK2MSFTNGP09.phx.gbl...
[Quoted Text] > Thank you very much!!! > > Where can i obtain more information about Redemtion? And how can i include > this dll in my projects? > > > > "Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje > news:exrmdYiPGHA.3976[ at ]TK2MSFTNGP10.phx.gbl... > You still have to use CDO. You can get the item's EntryID and StoreID from > Outlook and then use them with the Session.GetItem method to get the > corresponding item with CDO. > > "David Cebrian" <david_cebrian[ at ]msn.com> wrote in message > news:%239S9URiPGHA.3896[ at ]TK2MSFTNGP15.phx.gbl... >> Hello Sue, >> >> But if I want to use the recipient object of an email or an appointment >> item, then the example don't run. Because the objects recipient from > outlook >> are different to the object repient of the CDO, and the property Fields >> don't exists in the object recipient of outlook. > >> >> "Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> escribió en el mensaje >> news:eeAn$jfPGHA.3924[ at ]TK2MSFTNGP14.phx.gbl... >> You'd need to use the appropriate MAPI property tag with the CDO >> AddressEntry.FIelds collection. See http://www.cdolive.com/cdo10.htm. I > have >> a Redemption sample at http://www.outlookcode.com/codedetail.aspx?id=594> as >> well, if you want to avoid security prompts. >> >> >> "David Cebrian" <david_cebrian[ at ]msn.com> wrote in message >> news:%23s3BPDfPGHA.3260[ at ]TK2MSFTNGP11.phx.gbl... >>> Hello again everybody, >>> >>> I have a problem with CDO, I use the Addressbook method to search in the >>> contacts, stored in outlook or exhange, to select someones, when they are >>> selecteds I want to obtain the telephone number, when the contact is >> stored >>> in outlook, no problem I know how i do, but the problem is when i select > a >>> contact from exchange. >>> >>> I am a VB.NET programmer, and my project is an Add-in for Outlook. >>> >>> This is the code: >>> >>> SMScontactes = New Collection >>> >>> ' start CDO session >>> >>> m_CDO.Logon("outlook", , False, False) >>> >>> >>> >>> ' show address book >>> >>> CDOrecips = CType(m_CDO.AddressBook(, "Seleccione los Destinatarios del >>> SMS", , , 1, "Destinatarios", , ), MAPI.Recipients) >>> >>> >>> >>> For n = 1 To CType(CDOrecips.Count, Integer) >>> >>> CDOrecip = CType(CDOrecips.Item(n), MAPI.Recipient) >>> >>> strID = CType(CDOrecip.ID, String) >>> >>> strID = Microsoft.VisualBasic.Strings.Right(strID, Len(strID) - 72) >>> >>> strID = Microsoft.VisualBasic.Strings.Left(strID, Len(strID) - 6) >>> >>> contacte = CType(apli.GetNamespace("mapi").GetItemFromID(strID), >>> Outlook.ContactItem) >>> >>> If Not contacte Is Nothing Then >>> >>> SMScontactes.Add(contacte) >>> >>> txtPara.Text = txtPara.Text & contacte.FullName & "(" & >>> contacte.MobileTelephoneNumber & ");" >>> >>> Else >>> >>> MsgBox("No es un contacto de Outlook") >>> >>> End If >>> >>> Next >>> >>> ' release objects >>> >>> m_CDO.Logoff() >
|
|
|