Discussions
Categories
- 17.9K All Categories
- 3.4K Industry Applications
- 3.3K Intelligent Advisor
- 63 Insurance
- 536.4K On-Premises Infrastructure
- 138.3K Analytics Software
- 38.6K Application Development Software
- 5.8K Cloud Platform
- 109.5K Database Software
- 17.5K Enterprise Manager
- 8.8K Hardware
- 71.1K Infrastructure Software
- 105.3K Integration
- 41.6K Security Software
How to send an email from the HFM Rules

Hi experts,
Has anyone achieved this On-Prem or OMCS? I am planning to trigger this using an on-demand rule, but not sure where to start.
Thanks to all for any ideas, opinions, recommendations and working solutions you may have.
Bulent
Best Answer
-
Hi Bulent
This is the code I use for sending an email from the Allocate function:
intSendUsing = 2
intSMTPPort = 25
' Don't want any errors to hold up the process
On Error Resume Next
'Create CDO configuration object
Set objConfig = CreateObject("CDO.Configuration")
'Set Config object settings
With objConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = intSendUsing
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = intSMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
'Create CDO message object
Set objMsg = CreateObject("CDO.Message")
'Assign config object to configuration property of message object
Set objMsg.Configuration = objConfig
'Set Message object settings and send mail
With objMsg
.To = strToAddress
.CC = strCCAddress
.From = strFromAddress
.Subject = strSubject
.TextBody = strEmailMsgLine
.Send
End With
'Destroy message objects
Set objMsg = Nothing
Set objConfig = Nothing
Answers
-
-
Hi Bulent
This is the code I use for sending an email from the Allocate function:
intSendUsing = 2
intSMTPPort = 25
' Don't want any errors to hold up the process
On Error Resume Next
'Create CDO configuration object
Set objConfig = CreateObject("CDO.Configuration")
'Set Config object settings
With objConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = intSendUsing
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = intSMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
'Create CDO message object
Set objMsg = CreateObject("CDO.Message")
'Assign config object to configuration property of message object
Set objMsg.Configuration = objConfig
'Set Message object settings and send mail
With objMsg
.To = strToAddress
.CC = strCCAddress
.From = strFromAddress
.Subject = strSubject
.TextBody = strEmailMsgLine
.Send
End With
'Destroy message objects
Set objMsg = Nothing
Set objConfig = Nothing
-
Hello,
Thank you for this. Using the CDO method, do you know if the email goes through the Microsoft servers? This may be a problem if I need to include some financial figures in the email.
Regards
Bulent
-
Hi Eric,
I have seen your book about sending emails from HFM rules on Amazon. I have found some code on the internet (CDO / Outlook object) alsouser6692921 shared a sample code using CDO object. Is your book offering any other useful information and/or methods? I am happy to purchase it if it does. I'd appreciate if you could let me know.
Thanks
Bulent
-
Hi Bulent
The email will not go through Microsoft servers unless your SMTP server is a Microsoft server. SMTP is essentially a folder which is monitored by the SMTP service. An SMTP email is a file in a particular format which is copied to a set folder on the SMTP Server. The SMTP Service picks up the file and reads the email properties and then sends the email from the server itself.
SMTP does not require any software installation as it is a folder that is being monitored. If you want to go down the Outlook route you will need to have mail client software installed i.e. you need to install Outlook on your HFM servers. Or replicate the SMTP setup by copying the email as a text file to another server which has Outlook installed and monitor the folder.
HTH
-
Thanks HTH,
This is good to hear. It would be great to have some kind of proof of this (e.g. a document or website explaining how CDO works). I have googled for this but couldn't find much about how the data (email and config data) flows using CDO.
Code like "http://schemas.microsoft.com/cdo/configuration" may make it look like some of the information is being recorded in the Microsoft databases.
Regards
Bulent