Outlook user property

message from John on 20 May 2004
Hi

I am trying to open a new outlook message and add a user defined property to
it, from within MS Access using the below code. I am getting an 'Object
variable or With block variable not set' error on the highlighted line. What
am I doing wrong?

Thanks

Regards

' MS Access code follows

Private WithEvents objOutlook As Outlook.Application
Private WithEvents objOutlookMsg As Outlook.MailItem

Sub NewMail()
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

eto = "test@xxxxtestxxx.com"
esubject = ""

Email_ID = GetGUID

Dim x As UserProperty

x = objOutlookMsg.UserProperties.Add("CompanyID", olText) ' <=== error
on this line
objOutlookMsg.UserProperties.Item("CompanyID").Value = Str(Me.ID)

objOutlookMsg.To = eto
objOutlookMsg.Display
End Sub
 
Van T. Dinh replied to John on 19 May 2004
Even though you are doing this in Access using Automation,
the code is much more related to Outlook rather than
Access.

Suggest you re-post the question to one of the Outlook
newsgroups.

HTH
Van T. Dinh
MVP (Access)

defined property to
getting an 'Object
highlighted line. What
olText) ' <=== error
Str(Me.ID)
 

Archived message: Outlook user property (MS Access)