Outlook user property

J

John

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 = "(e-mail address removed)"
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
 
V

Van T. Dinh

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)
 

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

Top