Setting "File as" property via CDO

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hi all,

Can someone help me with this code. I am trying to set the
CdoContact_FileUnder for a Contact but keep getting a type mismatch error on
" .Add CdoContact_FileUnder, CdoMessage.Subject"

Thanks.

Const CdoContact_FileUnder = "0x8005"
Const CdoPR_DISPLAY_NAME = &H3001001E

' On Error Resume Next
Set objMAPI = CreateObject("MAPI.Session")
objMAPI.Logon "", "", False, True, 0, True, "MAILSERVER" & vbLf &
"administrator"

Set objContFolder = objMAPI.GetDefaultFolder(5)

Set CdoMessages = objContFolder.Messages

Set CdoMessage = CdoMessages.Add

CdoMessage.Subject = "John Doe"

CdoMessage.Type = "IPM.Contact"

Set objFields = CdoMessage.Fields

With objFields

.Add CdoPR_DISPLAY_NAME, "John Doe"
.Add CdoContact_FileUnder, CdoMessage.Subject
' .Add CdoContact_FileUnderID, &HFFFFFFFF, CdoPropSetID3

End With

CdoMessage.Update True, True
 
..Add CdoContact_FileUnder, vbString, CdoMessage.Subject, CdoPropSetID3
 
Thanks Kevin,

Just out of curiosity, what is the "vbString" for?

Thanks again.
 
It's Ken.

If you look at the CDO help you will see that when you add a property that
isn't predefined as to Type you have to assign the type for the new field.
vbString denotes the new field as a string field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top