dcarrion
asked on
Add a contact to mailbox using MAPI Session
Hello...All I want to do is get this damn thing to add a contact to a mailbox...I can't see what I am doing wrong.
Dim oFolder As Object
Dim oAddressEntries As Object
Dim CdoPR_DISPLAY_NAME As Object
Dim oFields As Object
Dim oAddr As Object
Dim CdoPR_EMAIL_ADDRESS As Object
Dim CdoDefaultFolderContacts As Object
Dim CDOSession As Object = CreateObject("MAPI.Session ")
CDOSession.Logon(, , , , , , "10.0.1.11" & vbLf & "Somones Mailbox")
oFolder = CDOSession.GetDefaultFolde r(CdoDefau ltFolderCo ntacts)
oAddressEntries = oFolder.Messages
oAddr = oAddressEntries.Add(, , "IPM.Contact") <============= THIS ONE
oFields = oAddr.Fields
oFields.Add(CdoPR_DISPLAY_ NAME, "Someones Name")
oFields.Add(CdoPR_EMAIL_AD DRESS, "bla@seanmccormick.com")
oAddr.Update()
It works when I use the NameSpace but not MAPI.Session. The error is:
An unhandled exception of type 'System.Reflection.TargetP arameterCo untExcepti on' occurred in microsoft.visualbasic.dll
Additional information: Invalid number of parameters.
On the line with the arrow ^
I really want to do it this way because I don't want to use the Outlook client...Please help this is urgent for a project I am doing...Thanks for your help
Dim oFolder As Object
Dim oAddressEntries As Object
Dim CdoPR_DISPLAY_NAME As Object
Dim oFields As Object
Dim oAddr As Object
Dim CdoPR_EMAIL_ADDRESS As Object
Dim CdoDefaultFolderContacts As Object
Dim CDOSession As Object = CreateObject("MAPI.Session
CDOSession.Logon(, , , , , , "10.0.1.11" & vbLf & "Somones Mailbox")
oFolder = CDOSession.GetDefaultFolde
oAddressEntries = oFolder.Messages
oAddr = oAddressEntries.Add(, , "IPM.Contact") <============= THIS ONE
oFields = oAddr.Fields
oFields.Add(CdoPR_DISPLAY_
oFields.Add(CdoPR_EMAIL_AD
oAddr.Update()
It works when I use the NameSpace but not MAPI.Session. The error is:
An unhandled exception of type 'System.Reflection.TargetP
Additional information: Invalid number of parameters.
On the line with the arrow ^
I really want to do it this way because I don't want to use the Outlook client...Please help this is urgent for a project I am doing...Thanks for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.