SetSmtpOptions

The SetSmtpOptions method configures the algorithm to use in the connection with the SMTP server and using the SendSmtpMailEx method.

 

This function must be called before SendSmtpMailEx.

 

 

Syntax

ActiveX:

void SendSmtpOptions(System.Integer smtpOptions)

DLL:

void SendSmtpOptions(long smtpOptions)

 

Parameters

smtpOptions

Specify one or more options from the following enumerator:

 

Flags

Description

Value (Hex)

Value* (Dec)

SMTP_OPTION_SECURE

Indicates the need for a secure connection. Default is FALSE. This option is automatically set to TRUE if the port number are 465 or 587.

0x00000001

1

SMTP_OPTION_USESTARTTLS

Use the STARTTLS command. Default is FALSE. This option is automatically set to TRUE if the port number is 587.

0x00000002

2

SMTP_OPTION_FORCESECURE

Do not communicate unless secure communication can be established.  Default value is FALSE.

0x00000004

4

SMTP_OPTION_NON_BLOCKING_MODE

Enable non-blocking mode of the TCP/IP socket. Default is FALSE (hence blocking is enabled). If this option is set, the socket will be configured to non-blocking, and all time-outs will be handled at the application level. This option can be used when there are issues related to the connection that cannot be resolved otherwise. In particular, when is set, the initial connection time-out can be regulated by the SMTP_TIMEOUT_CONNECT value in SendSmtpMailTimeout. If this options is not set ( the default) all time-outs configured by SendSmtpMailTimeout will be handled by the socket, except for the initial connection time-out that will be (usually) 1 minute.

0x00000008

8

SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE

Enable allowing unsecure certificates from the SMTP server. Default is FALSE. This option can be used for debugging, when the available SMTP server is using a self-signed certificate.

0x00000010

16

SMTP_OPTION_TRACE_REMOVE_CRLF

Remove CRLF combinations from the line ends in the trace file: enhance notepad++ viewing. This option breaks viewing the trace file in Windows notepad (line breaks will be lost).

0x40000000

‭1073741824

(*) NOTE: Converting from HEX DWORD, unsigned and 32-bit unit of data

 

Remarks

This function must be called before SendSmtpMailEx.

 

The function must be called once for all settings to be modified.

All options are FALSE by default.

 

The specific algorithm that is used (SSL 2.0, SSL 3.0, TLS 1.0, TLS 1.1, TLS 1.2) depends on which algorithms are enabled in Windows (see https:// technet.microsoft.com/en-us/library/security/3009008.aspx) and the highest algorithm negotiated between client and server.

 

Activating secure communications is done by specifying port 465 or by using the value SMTP_OPTION_SECURE to any other port number.

 

When port 587 is specified, STARTTLS is activated by default.  For any other port, the developer should use the SMTP_OPTION_USESTARTTLS to use STARTTLS.

 

Notes about Gmail®:

 

Member of CDIntfEx.CDIntfEx.

 

Example

<Flags()>

Public Enum SMTP_OPTIONS As Integer

    SMTP_OPTION_SECURE                      = &H00000001

    SMTP_OPTION_USESTARTTLS                 = &H00000002

    SMTP_OPTION_FORCESECURE                 = &H00000004

    SMTP_OPTION_NON_BLOCKING_MODE           = &H00000008

    SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE  = &H00000010

    SMTP_OPTION_TRACE_REMOVE_CRLF           = &H40000000

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)

 

    ' Set Secured connection

    SetSmtpOptions(SMTP_OPTIONS.SMTP_OPTION_SECURE Or SMTP_OPTIONS.SMTP_OPTION_FORCESECURE)

 

    ' Set SendSmtpMail

    PDF.SendSmtpMailEx("YOUR_SMTP_SERVER", 8025, "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_OPTIONS

{

    SMTP_OPTION_SECURE                      = 0x00000001,    

    SMTP_OPTION_USESTARTTLS                 = 0x00000002,    

    SMTP_OPTION_FORCESECURE                 = 0x00000004,    

    SMTP_OPTION_NON_BLOCKING_MODE           = 0x00000008,    

    SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE  = 0x00000010,    

    SMTP_OPTION_TRACE_REMOVE_CRLF           = 0x40000000

}

 

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);

 

    // Set Secured connection

    SetSmtpOptions((int)(SMTP_OPTIONS.SMTP_OPTION_SECURE | SMTP_OPTIONS.SMTP_OPTION_FORCESECURE));

 

    // Set SendSmtpMail

    PDF.SendSmtpMailEx("YOUR_SMTP_SERVER", 8025, "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);   

 

    // Set Secured connection

    SetSmtpOptions(SMTP_OPTION_SECURE | SMTP_OPTION_FORCESECURE);

 

    // Set SendSmtpMail

    SendSmtpMailEx("YOUR_SMTP_SERVER", 8025, "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_OPTIONS

    {

        SMTP_OPTION_SECURE(0x00000001),

        SMTP_OPTION_USESTARTTLS(0x00000002),

        SMTP_OPTION_FORCESECURE(0x00000004),

        SMTP_OPTION_NON_BLOCKING_MODE(0x00000008),

        SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE(0x00000010),

        SMTP_OPTION_TRACE_REMOVE_CRLF(0x40000000);

        public int value;

        public SMTP_OPTIONS(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);

 

        // Set Secured connection

        Dispatch.call(pdf,"SetSmtpOptions",SMTP_OPTIONS.SMTP_OPTION_SECURE.value | SMTP_OPTIONS.SMTP_OPTION_FORCESECURE.value);        

 

        // Set SendSmtpMail

        Dispatch.call(pdf,"SendSmtpMailEx", "YOUR_SMTP_SERVER", 8025, "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_OPTIONS = @{

    SMTP_OPTION_SECURE                      = 0x00000001    

    SMTP_OPTION_USESTARTTLS                 = 0x00000002

    SMTP_OPTION_FORCESECURE                 = 0x00000004

    SMTP_OPTION_NON_BLOCKING_MODE           = 0x00000008    

    SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE  = 0x00000010    

    SMTP_OPTION_TRACE_REMOVE_CRLF           = 0x40000000

}

 

# 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))

 

# Set Secured connection

[System.__ComObject].InvokeMember('SetSmtpOptions', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, $SMTP_OPTIONS::SMTP_OPTION_SECURE -bOr $SMTP_OPTIONS::SMTP_OPTION_FORCESECURE)

 

# Set SendSmtpMail

[System.__ComObject].InvokeMember('SendSmtpMailEx', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, 

    @("YOUR_SMTP_SERVER", 8025, "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_OPTIONS

Const SMTP_OPTION_SECURE                        = 1

Const SMTP_OPTION_USESTARTTLS                   = 2

Const SMTP_OPTION_FORCESECURE                   = 4

Const SMTP_OPTION_NON_BLOCKING_MODE             = 8

Const SMTP_OPTION_ALLOW_UNSECURE_CERTIFICATE    = 16

Const SMTP_OPTION_TRACE_REMOVE_CRLF             = ‭1073741824‬

 

' 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

 

' Set Secured connection

SetSmtpOptions SMTP_OPTION_SECURE Or SMTP_OPTION_FORCESECURE

 

' Set SendSmtpMail

PDF.SendSmtpMailEx "YOUR_SMTP_SERVER", 8025, "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