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
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