By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,160 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,160 IT Pros & Developers. It's quick & easy.

Outlook user property

P: n/a
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 = "te**@xxxxtestxxx.com"
esubject = ""

Email_ID = GetGUID

Dim x As UserProperty

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

objOutlookMsg.To = eto
objOutlookMsg.Display
End Sub
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.