The SendSmtpMailTimeout method modifies the default values for different time-outs using by SendSmtpMailEx method.
This function must be called before SendSmtpMailEx.
void SendSmtpMailTimeout(System.Integer timeoutType, System.Integer timeoutSeconds)
void SendSmtpMailTimeout(long timeoutType, long timeoutSeconds)
timeoutType
Specify the type of time-out to be modified.
The value for time-out Type can be any from the following the enumerator:
SMTP_TIMEOUTS_ENUM |
Value |
---|---|
SMTP_TIMEOUT_INIT_220 |
1 |
SMTP_TIMEOUT_MAIL_COMMAND |
2 |
SMTP_TIMEOUT_RCPT_COMMAND |
3 |
SMTP_TIMEOUT_DATA_INIT |
4 |
SMTP_TIMEOUT_DATA_BLOCK |
5 |
SMTP_TIMEOUT_DATA_END |
6 |
SMTP_TIMEOUT_CONNECT |
7 |
SMTP_TIMEOUT_HANDSHAKE |
8 |
timeoutSeconds
value of the time-out in seconds.
This function must be called before SendSmtpMailEx.
The function must be called once for each time out type to modify. If not called for some specific time out type, the default value will be assumed accordingly with this table:
Type Time Out |
Default Value (s) |
---|---|
SMTP_TIMEOUT_INIT_220 |
300 |
SMTP_TIMEOUT_MAIL_COMMAND |
300 |
SMTP_TIMEOUT_RCPT_COMMAND |
300 |
SMTP_TIMEOUT_DATA_INIT |
180 |
SMTP_TIMEOUT_DATA_BLOCK |
180 |
SMTP_TIMEOUT_DATA_END |
600 |
SMTP_TIMEOUT_CONNECT |
10 |
SMTP_TIMEOUT_HANDSHAKE |
60 |
These are values recommended by the specification RFC 5321 "Simple Mail Transfer Protocol 2008" section 4.5.3.2. except for SMTP_TIMEOUT_CONNECT and SMTP_TIMEOUT_HANDSHAKE that are provided by this implementation.
It was verified that when the DATA BLOCK timeout (SMTP_TIMEOUT_DATA_BLOCK) is set to a value less than 5 seconds, when the SMTP server is heavily loaded the communication fails: the server will close the socket and we must just quit the sending.
The default time-outs are by far enough for most applications, so the customers will not (probably) need to change these settings.
Member of CDIntfEx.CDIntfEx.
<Flags()>
Public Enum SMTP_TIMEOUTS_ENUM As Integer
SMTP_TIMEOUT_INIT_220 = 1
SMTP_TIMEOUT_MAIL_COMMAND = 2
SMTP_TIMEOUT_RCPT_COMMAND = 3
SMTP_TIMEOUT_DATA_INIT = 4
SMTP_TIMEOUT_DATA_BLOCK = 5
SMTP_TIMEOUT_DATA_END = 6
SMTP_TIMEOUT_CONNECT = 7
SMTP_TIMEOUT_HANDSHAKE = 8
End Enum
Public Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME As String = "Amyuni PDF Converter"
' Declare a new cdintfex object if it does not exist in the form.
Dim PDF As New CDIntfEx.CDIntfEx
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
PDF.DriverInit(AMYUNIPRINTERNAME)
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter()
' The EnablePrinter() method needs to be called right before each print job.
' and before the configuration
' Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter(strLicenseTo, strActivationCode)
' Change the Time-outs
' Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
PDF.SendSmtpMailTimeout(SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_DATA_BLOCK, 300)
' Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
PDF.SendSmtpMailTimeout(SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_CONNECT, 1)
' Set SendSmtpMail
PDF.SendSmtpMailEx("YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",
"C:\temp1.pdf;document1.pdf;C:\temp2.pdf;document2.pdf")
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter()
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd()
End Sub
[Flags()]
public enum SMTP_TIMEOUTS_ENUM
{
SMTP_TIMEOUT_INIT_220 = 1,
SMTP_TIMEOUT_MAIL_COMMAND = 2,
SMTP_TIMEOUT_RCPT_COMMAND = 3,
SMTP_TIMEOUT_DATA_INIT = 4,
SMTP_TIMEOUT_DATA_BLOCK = 5,
SMTP_TIMEOUT_DATA_END = 6,
SMTP_TIMEOUT_CONNECT = 7,
SMTP_TIMEOUT_HANDSHAKE = 8
}
public void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Converter Evaluation";
const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
const string AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it does not exist in the form.
CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfEx();
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
PDF.DriverInit(AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
PDF.SetDefaultPrinter();
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter(strLicenseTo, strActivationCode);
// Change the Time-outs
// Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
PDF.SendSmtpMailTimeout(SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_DATA_BLOCK, 300);
// Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
PDF.SendSmtpMailTimeout(SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_CONNECT, 1);
// Set SendSmtpMail
PDF.SendSmtpMailEx("YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",
"C:\temp1.pdf;document1.pdf;C:\temp2.pdf;document2.pdf");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter();
// This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd();
}
// PDF Converter Cpp.cpp : Defines the entry point for the console application.
//
# include <Windows.h>
# include <string>
# include "CdIntf.h"
# pragma comment (lib, "CDIntf.lib")
using namespace std;
int main()
{
// Constants for Activation codes
#define strLicenseTo "Amyuni PDF Converter Evaluation"
#define strActivationCode "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
#define AMYUNIPRINTERNAME "Amyuni PDF Converter"
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
HANDLE PDF = DriverInit(AMYUNIPRINTERNAME);
// The CDISetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
CDISetDefaultPrinter(PDF);
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
EnablePrinter(PDF, strLicenseTo, strActivationCode);
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
EnablePrinter(PDF, strLicenseTo, strActivationCode);
// Change the Time-outs
// Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
SendSmtpMailTimeout(SMTP_TIMEOUT_DATA_BLOCK, 300);
// Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
SendSmtpMailTimeout(SMTP_TIMEOUT_CONNECT, 1);
// Set SendSmtpMail
SendSmtpMailEx("YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",
"C:\temp1.pdf;document1.pdf;C:\temp2.pdf;document2.pdf");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
RestoreDefaultPrinter(PDF);
// This function will simply detach from an existing printer because the handle was created using DriverInit
DriverEnd(PDF);
// Destroy PDF object
PDF = nullptr;
return 0;
}
package Example;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
public class Sample {
public enum SMTP_TIMEOUTS_ENUM
{
SMTP_TIMEOUT_INIT_220(1),
SMTP_TIMEOUT_MAIL_COMMAND(2),
SMTP_TIMEOUT_RCPT_COMMAND(3),
SMTP_TIMEOUT_DATA_INIT(4),
SMTP_TIMEOUT_DATA_BLOCK(5),
SMTP_TIMEOUT_DATA_END(6),
SMTP_TIMEOUT_CONNECT(7),
SMTP_TIMEOUT_HANDSHAKE(8);
public int value;
public SMTP_TIMEOUTS_ENUM(int value)
{
this.value = value;
}
public Object value()
{
return value;
}
}
public static void main(String[] args)
{
// Constants for Activation codes
String strLicenseTo = "Amyuni PDF Converter Evaluation";
String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
String AMYUNIPRINTERNAME = "Amyuni PDF Converter";
// Declare a new cdintfex object if it does not exist in the form.
ActiveXComponent pdf = new ActiveXComponent("CDIntfEx.CDIntfEx.6.5");
// Get a reference to the installed printer.
// This will fail if the printer name passed to the DriverInit method is
// not found in the printer’s folder
Dispatch.call(pdf,"DriverInit",AMYUNIPRINTERNAME);
// The SetDefaultPrinter function sets the system default printer to the one
// initialized by the DriverInit functions.
Dispatch.call(pdf,"SetDefaultPrinter");
// The EnablePrinter() method needs to be called right before each print job.
// and before the configuration
// Calling the EnablePrinter() method will start a 20 second time-out value
Dispatch.call(pdf,"EnablePrinter", strLicenseTo, strActivationCode);
// Change the Time-outs
// Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
Dispatch.call(pdf,"SendSmtpMailTimeout", SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_DATA_BLOCK.value, 300);
// Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
Dispatch.call(pdf,"SendSmtpMailTimeout", SMTP_TIMEOUTS_ENUM.SMTP_TIMEOUT_CONNECT.value, 1);
// Set SendSmtpMail
Dispatch.call(pdf,"SendSmtpMailEx", "YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",
"C:\temp1.pdf;document1.pdf;C:\temp2.pdf;document2.pdf");
// The RestoreDefaultPrinter function resets the system default printer
// to the printer that was the default before the call to SetDefaultPrinter.
Dispatch.call(pdf,"RestoreDefaultPrinter");
// This function will simply detach from an existing printer because the handle was created using DriverInit
Dispatch.call(pdf,"DriverEnd");
// Destroy PDF object
pdf = null;
}
}
$SMTP_TIMEOUTS_ENUM = @{
SMTP_TIMEOUT_INIT_220 = 1
SMTP_TIMEOUT_MAIL_COMMAND = 2
SMTP_TIMEOUT_RCPT_COMMAND = 3
SMTP_TIMEOUT_DATA_INIT = 4
SMTP_TIMEOUT_DATA_BLOCK = 5
SMTP_TIMEOUT_DATA_END = 6
SMTP_TIMEOUT_CONNECT = 7
SMTP_TIMEOUT_HANDSHAKE = 8
}
# Constants for Activation codes
$strLicenseTo = "Amyuni PDF Converter Evaluation"
$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
$AMYUNIPRINTERNAME = "Amyuni PDF Converter"
# Declare a new cdintfex object if it does not exist in the form.
$PDF = New-Object -ComObject CDIntfEx.CDIntfEx.6.5
# Get a reference to the installed printer.
# This will fail if the printer name passed to the DriverInit method is
# not found in the printer’s folder
[System.__ComObject].InvokeMember('DriverInit', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$AMYUNIPRINTERNAME)
# The SetDefaultPrinter function sets the system default printer to the one
# initialized by the DriverInit functions.
[System.__ComObject].InvokeMember('SetDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
# The EnablePrinter()method needs to be called right before each print job.
# and before the configuration
# Calling the EnablePrinter()method will start a 20 second time-out value
[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($strLicenseTo, $strActivationCode))
# Change the Time-outs
# Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
[System.__ComObject].InvokeMember('SendSmtpMailTimeout', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($SMTP_TIMEOUTS_ENUM::SMTP_TIMEOUT_DATA_BLOCK, 300))
# Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
[System.__ComObject].InvokeMember('SendSmtpMailTimeout', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, @($SMTP_TIMEOUTS_ENUM::SMTP_TIMEOUT_CONNECT, 1))
# Set SendSmtpMail
[System.__ComObject].InvokeMember('SendSmtpMailEx', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,
@("YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",
"C:\temp1.pdf;document1.pdf;C:\temp2.pdf;document2.pdf"))
# The RestoreDefaultPrinter function resets the system default printer
# to the printer that was the default before the call to SetDefaultPrinter.
[System.__ComObject].InvokeMember('RestoreDefaultPrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
# This function will simply detach from an existing printer because the handle was created using DriverInit
[System.__ComObject].InvokeMember('DriverEnd', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF,$null)
# Destroy PDF object
$PDF = $null
' SMTP_TIMEOUTS_ENUM
Const SMTP_TIMEOUT_INIT_220 = 1
Const SMTP_TIMEOUT_MAIL_COMMAND = 2
Const SMTP_TIMEOUT_RCPT_COMMAND = 3
Const SMTP_TIMEOUT_DATA_INIT = 4
Const SMTP_TIMEOUT_DATA_BLOCK = 5
Const SMTP_TIMEOUT_DATA_END = 6
Const SMTP_TIMEOUT_CONNECT = 7
Const SMTP_TIMEOUT_HANDSHAKE = 8
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Converter Evaluation"
Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
Const AMYUNIPRINTERNAME = "Amyuni PDF Converter"
' Declare a new cdintfex object
Dim PDF
Set PDF = CreateObject("CDIntfEx.CDIntfEx.6.5")
' Get a reference to the installed printer.
' This will fail if the printer name passed to the DriverInit method is
' not found in the printer’s folder
PDF.DriverInit AMYUNIPRINTERNAME
' The SetDefaultPrinter function sets the system default printer to the one
' initialized by the DriverInit functions.
PDF.SetDefaultPrinter
' The EnablePrinter() method needs to be called right before each print job.
' and before the configuration
' Calling the EnablePrinter() method will start a 20 second time-out value
PDF.EnablePrinter strLicenseTo, strActivationCode
' Change the Time-outs
' Increase the data blocks timeout from 180 seconds to 300 seconds, so a heavily loaded server still can handle the communications.
PDF.SendSmtpMailTimeout SMTP_TIMEOUT_DATA_BLOCK, 300
' Decrease the connection timeout from 10 seconds to 1 second so if the server cannot respond in 1 second the connection will be terminated. This feature is usable only for non-blocking sockets (see SetSmtpOptions)
PDF.SendSmtpMailTimeout SMTP_TIMEOUT_CONNECT, 1
' Set SendSmtpMail
PDF.SendSmtpMailEx "YOUR_SMTP_SERVER", 465, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",_
"Testing email capabilities", "Please find attached the requested document\nin PDF format.",_
"c:\temp\temp1.pdf;document1.pdf;c:\temp\temp2.pdf;document2.pdf"
' The RestoreDefaultPrinter function resets the system default printer
' to the printer that was the default before the call to SetDefaultPrinter.
PDF.RestoreDefaultPrinter
' This function will simply detach from an existing printer because the handle was created using DriverInit
PDF.DriverEnd
' Destroy PDF object
Set PDF = Nothing