Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with Outlook email via OLE

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
0
0
US
Hi,
I am trying to generate and display an email with Outlook using OLE objects.
This was working until a security update was applied to Windows and Outlook [Win 10, Outlook 2010].
Now, a popup appears with the following message.
A program is trying to send an e-mail message on your behalf.
[Allow] [Deny].
The problem is that when I click Allow, the email does not get displayed so the user can send it and I cannot figure out how to debug this.
I am pretty sure that the Outlook setting causing this is
[Warn me about suspicious activity when my antivirus software is inactive or out of date]
which is accessed in Outlook via File-> Options-> Trust Center-> Trust Center Settings…-> Programmatic Access
The problem is that I do not have administrative privileges and have been told that regardless we will not be allowed to disable this setting for security reasons.

My goal is to figure out why ALLOW is not letting the email get created/displayed.
It does not appear that the OLE Item functions provide a return status to indicate success or failure.

Prior to the update, the emails got displayed and could be sent without problems.
Sample code below:


// Use Ole code for Outlook
ole_outlook = Create OLEObject

TRY
// specify the COM "progID" that the class is registered with.
li_retval = ole_outlook.ConnectToNewObject("outlook.application")

// ConnectToNewObject() Returns 0 if it succeeds
// and one of the following values [below] if an error occurs:
IF li_retval < 0 THEN
// ConnectToNewObject() Error detected
Messagebox('Error','Error connecting to Outlook Email client. Error Code: ' + string(li_retval))
Return -1
END IF
CATCH (runtimeerror a)
Messagebox('Error','Error caught connecting to Outlook Email client. Process terminating.')
RETURN -1
END TRY

// Creates a new mail Item
ole_item = ole_outlook.CreateItem( 0 ) // '0' Mail Item

ole_item.To = 'Recipient Email Addr Goes Here'
ole_item.Subject = 'Test Email Subject'
ole_item.Display //displays the message without sending

--------------------------------------------------------------
This is when the popup dialog appears
A program is trying to send an e-mail message on your behalf.
[Allow] [Deny]
If I select Allow, the email still does not get displayed.
I cannot figure out how to troubleshoot.
--------------------------------------------------------------

I appreciate any suggestions.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top