Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automating Outlook
Message
From
14/03/2001 16:26:39
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00485010
Message ID:
00485063
Views:
12
>>* test001.prg
>>*
>>#define olContactItem 2
>>#define olBusiness 2
>>
>>I am just beginning looking into automating Outlook. I have the GRANOR/MARTIN book which explains this. On page 340 there is a fairly simple example of adding a contact to outlook which I have attempted to mimic (see below).
>>I runs smoothly but the contact does not show up in Outlook. Any ideas as to why ?
>>
>>
>>Local oNameSpace, oContact
>>if varType(oOutlook) <> "O"
>> wait "Creating Outlook Object Variable ... " window timeout 2
>> Release oOutlook
>> public oOutlook
>> oOutlook = createObject("Outlook.Application")
>>endif
>>cNameSpace = oOutlook.GetNameSpace("MAPI")
>>oContact = oOutlook.CreateItem(olContactItem)
>>with oContact
>> .FullName = "Shaina Dascher"
>> .PrimaryTelephoneNumber = "570-494-0664"
>> .Save() && Note: I know it goes thru this spot by using the debugger.
>>endwith
>>oOutlook.quit()
>>return
>
>My procedure goes:
>
>
>ooutlook = CreateObject("Outlook.Application")
>onamespace = ooutlook.GetNameSpace("MAPI")
>ofldrcontacts = onamespace.Folders("Personal Folders").Folders("Contacts").Folders("402 WWW Access")
>
>* Set the contact reference to the new contact
>oitem = ofldrcontacts.Items.Add


Well, I just found out what was wrong (as strange as it is).
The variable cNameSpace should have been oNameSpace.
When I changed it .... things worked.  
Now, this doesn't make sense to me.  How could the spelling of that 
variable name make a difference.  It doesn't even get referenced after that.
Puzzled.

>
>
>  * Set properties of the contact
>  WITH oitem
>      .FirstName = txtContactFirstName
>      .LastName = txtContactLastName
>      .FileAs = .LastName + ", " + .FirstName
>      .Email1Address = txtEmailAddress
>      .Email1AddressType = 'SMTP'
>      .JobTitle = txtContactTitle
>      .CompanyName = txtCompanyName
>      .BusinessAddressStreet = txtAddress
>      .BusinessAddressCity = txtCity
>      .BusinessAddressState = txtRegion
>      .BusinessAddressPostalCode = txtPostalCode
>      .BusinessAddressCountry = txtCountry
>      .BusinessTelephoneNumber = txtPhone
>      .BusinessFaxNumber = txtFax
>      .GovernmentIDNumber = LOWER(txtgovernid)
>      .CustomerID = LOWER(txtcustid)
>      .JobTitle = memoreason
>      .User1 = txtUserField1
>      * Save the contact
>      .Save
>    ENDWITH
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform