Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Preconfigurations Sending the e-mails by the application

Creates object PmFolder with methods and panel for sending e-mails from the application.
 
This preconfiguration can be activated when creating a new object (e.g. by "New object" in the local object menu or by pressing the Insert key after selecting the object) and is included in the group: " / Communications / Email".

This preconfiguration can be used with the objects: PmFolder or PmRoot.

 
- Preconfiguration creates an object of type PmFolder containing the SendEmail method with the sTo, sSubject, sBody parameters. At the start, there are variables that set the SMTP server connection and at the end the SendEmailCDO method is called that send the message.
- The preconfiguration also includes a graphic panel, but it is not necessary for sending messages. It contains graphic items used for entering the receiver e-mail address, the messasge subject and the message body. There is also a PmiButton item, that calls the SendEmail method with the defined values on the onButtonUp event..
- In the window that appears before the object is created, it is necessary to enter the information needed for SMTP server configuration and message sender identification.
- The preconfiguration is created including the panel (PmPanel object) functionality as a WEB panel. In order to make the preconfiguration functional also for the WEB, it is necessary to enable the PmPanel object for the WEB (on the Web Server page).
 
The panel method SendEmail can be called anywhere from the application.
These configurators can be set before the preconfiguration is created:
The name of created objectName of the object created in the application object tree. This is a system name and must not contain empty string, diacritics, spaces and the first character must not be a number.

Default: "SendEmail"

SMTP server adress
Your UserID on the SMTP server
Your password on the SMTP server
Name sender
Mail addres sender
Script for sending an e-mail:
Dim nSendUsing, oMsg, oFlds, nSmtpAuthenticate, sSmtpServer
Dim sUserName, sPassword, nSmtpServerPort, bSmtpUseSsl, nSmtpConnectionTimeout
  
nSendUsing = 2 '1 = Send message using the local SMTP service pickup directory, 2 = Send the message using the network (SMTP over the network)
sSmtpServer = "smtp.aol.com" 'Name or IP of Remote SMTP Server
nSmtpAuthenticate = 1 'Type of authentication, NONE=0, Basic=1 (Base64 encoded), NTLM=2
sUserName ="My Name" & "<you@aol.com>" 'Your UserID on the SMTP server
sPassword = "******" 'Your password on the SMTP server
nSmtpServerPort = 25 'Server port (typically 25)
bSmtpUseSsl = false 'Use SSL for the connection (false or true)
nSmtpConnectionTimeout = 60 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
  
Set oMsg = CreateObject("CDO.Message")
oMsg.BodyPart.Charset = "utf-8" ' "windows-1252" or "iso-8859-2" / ...
oMsg.Subject = "Test email from Promotic"
oMsg.From = "Name" & "<my@aol.com>"
oMsg.To = "xxxx@yahoo.com"
oMsg.TextBody = "Test email from Promotic.." & vbCrLf & "It was sent using SMTP authentication."
'oMsg.HTMLBody = "<h1>Test email from Promotic..</h1><p>It was sent using SMTP authentication.</p>"
oMsg.Addattachment "c:\temp\Text.txt"
  
'==This section provides the configuration information for the remote SMTP server==
Set oFlds = oMsg.Configuration.Fields
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = nSendUsing
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sSmtpServer
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = nSmtpAuthenticate
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sUserName
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPassword
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = nSmtpServerPort
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = bSmtpUseSsl
oFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = nSmtpConnectionTimeout
oFlds.Update
'==End remote SMTP server configuration section==
  
oMsg.Send
 
www.w3schools.com/asp/asp_send_email.asp, msdn2.microsoft.com/en-us/library/ms526694.aspx
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice