I have code that will paste information into an open message in Outlook, if there is no message being composed, it would start a new message. Prior to XOJO 2018 Release 2 this code worked quite well, now in Release 2, it mostly works, but it no longer catches the NilObjectException as indicated in the comment below.
Anyone have an idea as to why and/or what to do about it?
[code]dim d as new date
d.Day = d.day + ExpirationDays
dim HTMLB as String = Template_HTML.ReplaceAll("<%LargeFileLinks%>", Links_HTML).ReplaceAll("<%ExpirationDate%>", str(d.LongDate))
dim TextB as String = Template_Text.ReplaceAll("<%LargeFileLinks%>", Links_HTML).ReplaceAll("<%ExpirationDate%>", str(d.LongDate))
objApp = new OLEObject(“Outlook.Application”)
if objApp = nil then
dim c as new Clipboard
c.Text = TextB
MsgBox(“It appears that Outlook is not installed, the links have been copied to the Clipboard instead.”)
exit sub
else
try
objMail = objApp.ActiveInspector.CurrentItem 'This line is the one that is having an error
catch e as NilObjectException
try
objMail = objApp.CreateItem(0)
catch e2 as NilObjectException
dim c as new Clipboard
c.Text = TextB
MsgBox(“It appears that Outlook is not installed, the links have been copied to the Clipboard instead.”)
exit sub
end try
end try
if objMail <> nil then
objMail.Invoke(“Display”)
end if
try
if objMail <> nil then
objMail.Value(“HTMLBody”) = HTMLB + EndOfLine + EndOfLine + objMail.Value(“HTMLBody”)
else
dim c as new Clipboard
c.Text = TextB
MsgBox(“An error occured while copying the links to the email, the links have been copied to the Clipboard instead.”)
end if
catch e as OLEException
dim c as new Clipboard
c.Text = TextB
MsgBox(“An error occured while copying the links to the email, the links have been copied to the Clipboard instead.”)
end try
end if
if objMail <> nil then
objMail = nil
end if
[/code]