Using secman.dll for sending multiple emails.

Add-in Express™ Support Service
That's what is more important than anything else

Using secman.dll for sending multiple emails.
secman stops sending messages. 
Robin Anderson


Guest


Hello support.

I have an app (written in Delphi Seattle-10) that uses the VCL version of Outlook Security Manager (V801-b0502) to send "notifications" to a database of clients (i.e. employees). I've used the sample code provided to create an OleObject; used the TOlSecurityManager object to connect; and the message.GetInspector.Activate for the first message then message.Send for the remainder.

It works incredibly well for users with a small number of clients.

I have a user that is sending 100-150 emails (using Outlook 2010) and the process stops mid session. I have added pacing to slow down the process as some ISPs stop sending thinking it's a spam blast (app goes to sleep every 30 seconds after sending 20 emails).

My code inside the loop of "counts" looks like this:

try
oOutLook := CreateOleObject( 'OutLook.Application' );

oSecurity.ConnectTo( oOutLook );
oSecurity.DisableOOMWarnings := True;

... create the message

if ( iSent = 0 ) then
oMessage.GetInspector.Activate
else
oMessage.Send;
finally
oSecurity.DisableOOMWarnings := False;
VarClear( oMessage );
VarClear( oOutLook );
end;

Should I be doing something different? Any help would be greatly appreciated.
Thanks
R
Posted 20 Dec, 2016 17:42:47 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Hello Robin,

You can create OutLook.Application and setup the oSecurity outside of the loop. That is, modify the code so that the loop only contains the code related to sending emails.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Dec, 2016 07:25:33 Top
Robin Anderson


Guest


Thanks Andrei.

As I was cobbling the forum message together, I wondered if the components could be outside the loop. I also noticed the update and downloaded v803-b0504.

Cheers and best holiday wishes.
R
Posted 21 Dec, 2016 11:00:08 Top
Robin Anderson


Guest


Hello Support.

I'm not sure about the "VarClear( oOutlook )" statement in the above snippet. Should this also be outside the loop as well?

Thanks for the assistance.

fyi: This little DLL has been a tremendous asset in my apps and has worked like magic. The scenario I'm having difficulties with is the first occurrence of a "large" amount of emails.

Cheers.
R
Posted 21 Dec, 2016 12:48:20 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Hello Robin,

Thank you for the kind words!

The sequence is: 1) start Outlook and set up the Outlook Security Manager, 2) send as many emails as required, 3) clean everything up.


Andrei Smolin
Add-in Express Team Leader
Posted 22 Dec, 2016 07:00:22 Top
Robin Anderson


Guest


Hello support.

I've put creating the Outlook and message objects outside the loop:

var
oOutlook, oMessage: OleVariant;
...
oOutLook := CreateOleObject( 'OutLook.Application' );
oMessage := oOutLook.CreateItem( MAIL_ITEM );
oSecurity.ConnectTo( oOutLook );
oSecurity.DisableOOMWarnings := True;

but I get a runtime error assembling the message(s).

oMessage.To := aQueue_[i].EMail;
oMessage.Subject := edtSubject.Text;
oMessage.Body := sBody;
oMessage.Attachments.Clear;
oMessage.Attachments.Add( sDocument );

if rbEMDisplay.Checked then
oMessage.GetInspector.Activate
else
oMessage.Send;

I'm assuming I must "clear" the attachments before adding a new one... but "Method 'Clear' not supported by automation object'.

Any guidance would be greatly appreciated.

Thanks,
R
Posted 17 Jan, 2017 11:22:36 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
Hello Robin,

The algorithm is this:

Start Outlook.
Create Security Manager.
Connect it to Outlook.
Disable OOM warning.
Loop:
Create a message
Setup the message
Send the message
End of loop

Enable OOM warnings
Disconnect Security Manager from Outlook
Free Security Manager
Free Outlook

Robin Anderson writes:
I'm assuming I must "clear" the attachments before adding a new one


I don't understand why would you need to do so. To delete all attachments, you scan the Attachments collection in the reverse order and, in the loop, delete the current attachment.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Jan, 2017 05:29:39 Top
Robin Anderson


Guest


Thanks Andrei.

I was using another component if Outlook was not detected sending the emails. I was only using one instance of the object and thought I could use the single message instance for the Outlook messages.

Should I "free" the object in the loop before creating a new message?
Posted 18 Jan, 2017 10:40:11 Top
Andrei Smolin


Add-in Express team


Posts: 19138
Joined: 2006-05-11
You need to create a message whenever you need to have a new message.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Jan, 2017 11:02:51 Top