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:
"/ Communication / Protocols and other communications / Email".
This preconfiguration can be created in the object:
PmaFolder or
PmaRoot.
- The preconfiguration creates an object of the
PmaFolder type containing the
SendEmail method with the
sTo,
sSubject,
sBody parameters. At the beginning, 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 panel, but it is not necessary for sending messages. It contains
Pmg objects used for entering the receiver e-mail address, the message subject and the message body. There is also a
PmgButton object, that calls the
SendEmail method with the defined parameters in 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 (object of the
PmaPanel type) is functional also a
Web panel. In order to make the preconfiguration functional also on the Web, it is necessary to enable the object of the
PmaPanel type for the Web (on the "
Web server" tab).
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 object | Name of the object created in the tree of Pma objects. The maximum name length is 30 characters. This is a system name, so it must contain only alphanumeric and must not contain any diacritics (i.e. national dependent chars), empty string, spaces and the first character must not be a number.
Default: "SendEmail" |
|
SMTP server address | |
Your UserID on the SMTP server | |
Your password on the SMTP server | |
Name sender | |
Mail address sender | |
---|
Script for sending an e-mail:
JavaScriptVBScriptSelect and copy to clipboard
var nSendUsing, oMsg, oFlds, nSmtpAuthenticate, sSmtpServer, 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 address 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 (usually 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)
oMsg = Pm.AxGetObject("new", "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..\nIt 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==
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 of remote SMTP server configuration section==
oMsg.Send();
Dim nSendUsing, oMsg, oFlds, nSmtpAuthenticate, sSmtpServer, 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 address 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 (usually 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 = Pm.AxGetObject("new", "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 of remote SMTP server configuration section==
oMsg.Send
http://www.w3schools.com/asp/asp_send_email.asp,
http://msdn2.microsoft.com/en-us/library/ms526694.aspx