VISUAL Did You Know?

If you have any questions about Infor VISUAL, contact us at 800.804.4715. We would be happy to help you!

Do you have VISUAL and want monthly tips and news? Subscribe to the BizTech VISUAL eNewsletter.

Are you looking for an ERP software? Subscribe to our monthly eNewsletter about ERP selection & implementation. Subscribe to the BizTech intERPreter.

Join the VISUAL Manufacturing Group on LinkedIn!

Search This Blog

Tuesday, April 21, 2009

Use CDO in VISUAL Macros to Send Emails

Did you know that you can easily use CDO in VISUAL macros to send emails?

In the code below, items in red are fields from the current order:

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

'==This section builds the email.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Order Number " & ORDER_ID
objMessage.From = "Your Company Name <
company@yourdomain.com>"
objMessage.To = CONTACT_FIRSTNAME & " " & CONTACT_LASTNAME & " <" & CONTACT_EMAIL & ">"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.yourdomain.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourusername"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

You can simply put the above code into a new macro to send an email to the contact on the current sales order. The code would need to be modified to use your email server, and it would need to be developed to include a summary of the current order.

BizTech VISUAL Consultant Darren Farmer provided this edition of VISUAL Did You Know™

No comments:

Post a Comment