Please help me with the title.
The following code, which worked properly in a 32-bit environment, will fail in a new environment:
Reference settings have been checked for Microsoft Office 16.0 Object Library.
According to the olMailItem properties, the subject is included, but there seems to be an error between To and Body.Also, if you look at the watch expression, the To and Body types are displayed as Variant/Integer.
Also, the Send method fails, but it works until Save.
The same symptom also occurred when the code was not set to reference setting.
I would appreciate it if you could let me know how to run the Send method.
error message
Runtime error '287'—Application definition or object definition error.
code
Sub S01()'Reference settings are used.
DimolAppObjAsOutlook.Application
DimmailObjAsOutlook.MailItem
Dim toAddress As String
SetolAppObj=New Outlook.Application
SetmailObj=olAppObj.CreateItem(olMailItem) 'Type name of item to be specified =olMailItem, value = 0
toAddress="********@*****"
With mailObj
.To=toAddress
.Subject="*****"
.Body="*****"
.BodyFormat=olFormatHTML
End With
mailObj.Send
SetolAppObj=Nothing
Set mailObj=Nothing
End Sub
Thank you for your comment.
I tried various means, but it didn't work, so when I contacted the management department at work, the unique security settings seemed to be interfering.
The code itself was probably fine, and it was a matter of our own environment.
I'm sorry for the trouble.
© 2024 OneMinuteCode. All rights reserved.