>I am trying to setup a program to autosend email based upon event messages on my server. However, any automation to Outlook/MAPI I've tried kicks up the annoying message stating a potentially hostile program is trying to send a message and wants me to press "yes" - a far cry from automatic!
>
>Does anyone have a simple workaround to this that doesn't involve an expensive add-on control?
You need
Outlook Redemption written by Outlook MVP Dmitry Streblechenko.
Here's some code I experimented with. I don't guarantee it, but it will get you started:
*!* =========================================== *!*
*!* Automate Outlook to send mail with attachments
*!* NOTE: Due to security issues with Outlook 2000 SPx and above
*!* this class depends on the presence of the Redemption.DLL
*!*
http://www.dimastr.com/redemption/home.htmDEFINE CLASS cusOutlookAutomation AS Custom
*!* Regular email properties
Recipients = ""
Subject = ""
Body = ""
Attachments = ""
oSendButton = ""
oMailITem = ""
oOutlook = ""
oSafeMailItem = ""
*!* =========================================== *!*
FUNCTION Init()
WITH THIS
*!* Outlook will only run one instance. This will get a handle if one is already running.
.oOutlook = GETOBJECT(, "Outlook.Application")
ENDWITH
ENDFUNC
*!* =========================================== *!*
FUNCTION CreateItem()
WITH THIS
*!* The Outlook email Item
.oMailItem = .oOutlook.CreateItem(0) && olMailItem
*!* The SafeMailItem which we can actually send
.oSafeMailItem = CREATEOBJECT("Redemption.SafeMailItem")
.oSafeMailItem = .oMailItem
*!* Populate the properties
.oSafeMailItem.To = .Recipients
.oSafeMailItem.Subject = .Subject
.oSafeMailItem.Body = .Body
.oSafeMailItem.Attachments.Add(.Attachments)
*!* "Send" the item to the Outbox
.oSafeMailItem.Recipients.ResolveAll()
*..Send()
ENDWITH
ENDFUNC
*!* =========================================== *!*
*!* This sends all the items in the Outbox at once
FUNCTION Send()
WITH THIS
.oSafeMailItem.Send()
*.oMapiUtils.DeliverNow()
*!* We must use the Outlook Send button to actually send the messages
*!* Get the object reference to the Outlook Send button
.oSendButton = .oOutlook.ActiveExplorer.CommandBars.FindControl(1, 5488)
.oSendButton.Execute()
ENDWITH
ENDFUNC
ENDDEFINE