PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Re: elementary VBA code

Reply

Re: elementary VBA code

 
Thread Tools Rate Thread
Old 20-09-2003, 09:51 PM   #1
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: elementary VBA code


Besides contact items (ContactItem), you can also have distribution lists
(DistListItem) objects in the Contacts folder. Modify your code as follows
(dim MyContactItem as Object and check the value of the Class property to
make sure you have a ContactItem object)

1.Public Sub AddFax()
2. Dim MyContactFolder As MAPIFolder
3. Dim MyContactItem As Object
4. Set MyContactFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
5. For Each MyContactItem In MyContactFolder.Items
5a If MyContactItem.Class = 40 Then
6. If MyContactItem.BusinessFaxNumber <> "" Then
.........
7. MyContactItem.Save
8. End If
8a End If
9. Next
10.End Sub


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Meenu Hodiwalla" <meenu_hodiwalla@bluemail.ch> wrote in message
news:958d01c37fb7$1e578220$a601280a@phx.gbl...
> I copied the following VBA code from a book :
>
> 1.Public Sub AddFax()
> 2. Dim MyContactFolder As MAPIFolder
> 3. Dim MyContactItem As ContactItem
> 4. Set MyContactFolder = Application.GetNamespace
> ("MAPI").GetDefaultFolder(olFolderContacts)
> 5. For Each MyContactItem In MyContactFolder.Items
> 6. If MyContactItem.BusinessFaxNumber <> "" Then
> .........
> 7. MyContactItem.Save
> 8. End If
> 9. Next
> 10.End Sub
>
> But I get run time error 13 (type mismatch) for line 5 of
> this code. Can anyone help ?
> Thanks.
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off