Send Mail with Attachements (SMTP)

The SendSmtpMail function is used to send a message with one or more attachments using direct SMTP e-mail. The SendSmtpMailW function is the Unicode equivalent of the same function. There are no "W" versions for the ActiveX interface, because the normal versions accept Unicode as well as non-Unicode strings.

 

Syntax

ActiveX:

System.Int32 SendSmtpMail(System.String szHostname, System.Int32 lPort, System.String szFrom, System.String szTo, System.String szCC, System.String szBCC, System.String szSubject, System.String szMessage, System.String szfilenames)
System.Int32 SendSmtpMailEx(System.String szHostname, System.Int32 lPort, System.String szUsername, System.String szPassword, System.String szFrom, System.String szTo, System.String szCC, System.String szBCC, System.String szSubject, System.String szMessage, System.String szfilenames)

DLL:

long SendSmtpMail(LPCSTR szHostname, long lPort, LPCSTR szFrom, LPCSTR szTo, LPCSTR szCC, LPCSTR szBCC, LPCSTR szSubject, LPCSTR szMessage, LPCSTR szFilenames)
long SendSmtpMailW(LPCWSTR szHostname, long lPort, LPCWSTR szFrom, LPCWSTR szTo, LPCWSTR szCC, LPCWSTR szBCC, LPCWSTR szSubject, LPCWSTR szMessage, LPCWSTR szFilenames)
long SendSmtpMailEx(LPCSTR szHostname, long lPort, LPCSTR szUsername, LPCSTR szPassword, LPCSTR szFrom, LPCSTR szTo, LPCSTR szCC, LPCSTR szBCC, LPCSTR szSubject, LPCSTR szMessage, LPCSTR szFilenames)
long SendSmtpMailExW(LPCWSTR szHostname, long lPort, LPCWSTR szUsername, LPCWSTR szPassword, LPCWSTR szFrom, LPCWSTR szTo, LPCWSTR szCC, LPCWSTR szBCC, LPCWSTR szSubject, LPCWSTR szMessage, LPCWSTR szFilenames)

 

Parameters

szHostName

Name or IP address of server used to send e-mails.

lPort

SMTP port number on server used to send e-mails. The default value is 25.

This value can be modified with the follow flags to enable some features:

Flags

Description

Value

SMTP_SECUREPORT

Indicate the need for a secure connection.

0x80000000

SMTP_USESTARTTLS

Uses the STARTTLS protocole.

0x40000000

SMTP_FORCESECURESMTP

Do not communicate unless secure communication can be established.

0x20000000

VB6 and VBA users need to use the decimal value of 0x80000000, -2147483648, to avoid overflow or typemistake error.  Ex:  -2147483648 + 8025

 

szFrom

Name of the e-mail sender as it shows to the person receiving the e-mail.

szTo

Name and e-mail address of the e-mail destination. Multiple addresses can be specified by separating them with semi-colons (;).

szCC

Name and e-mail address of the e-mail Carbon Copy list. Multiple addresses can be specified by separating them with semi-colons (;).

szBCC

Handle Name and e-mail address of the e-mail Blind Carbon Copy list. Multiple addresses can be specified by separating them with semi-colons (;).

szSubject

Subject of the email.  Some servers require to use UTF8: as prefix to support Unicode text.

szMessage

E-mail message.

szFileNames

Series of file names and their captions as they should appear in the e-mail attachment. The file name is the full path of the file to send, the caption is the name of the file as seen by the recipient. The syntax for sending multiple files is as follows: file1;caption1;file2;caption2; etc.  No space allowed between the semicolon and the file path.

szUsername

username for SMTP server.

szPassword

Password for SMTP server.

 

Return Value

The SendSmtpMail and SendSmtpMailEx methodsreturn 0 if successful or an SMTP specific error code if an error occurs when sending the e-mail.

 

Remarks

It  should be an Ansi string for SendSmtpMail/SendSmtpMailEx or a Unicode string for SendSmtpMailW/SendSmtpMailExW.

 

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 adding the value SMTP_SECUREPORT to any other port number.

Example: if TLS/SSL is available on port 8025, the caller can specify port SMTP_SECUREPORT + 8025 to activate secure communications.

 

When port 587 is specified, STARTTLS is activated by default.  For any other port, the developer can add the flag SMTP_USESTARTTLS to use STARTTLS.

 

Notes about Gmail®:

Some SMTP servers don't allow direct Unicode for the text of the SMTP header, only UTF8 encoding.   In those cases, the UTF8:  prefix must be used for the subject field.  Ex: UTF8: Test subject ä ö ü Ä Ö Ü ß.  However, the conversion only will applied if there is any Unicode symbol.

 

Member of CDIntfEx.CDIntfEx.

Example SMTP without encryption

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "DOCX Converter Developer Evaluation"

    Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    Const AMYUNIPRINTERNAME As String = "Amyuni DOCX Converter"

 

    ' Declare a new cdintfex object if it does not exist in the form.

    Dim DOCX 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

    DOCX.DriverInit(AMYUNIPRINTERNAME)

 

    ' The SetDefaultPrinter function sets the system default printer to the one

    ' initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter()

 

    ' The EnablePrinter() method needs to be called right before each print job. 

    ' Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode)

 

    ' Set SendSmtpMail

    DOCX.SendSmtpMail("YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

                "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx")

 

    ' The RestoreDefaultPrinter function resets the system default printer 

    ' to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter()

 

    ' This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd()

 

    ' Destroy DOCX object

    DOCX = Nothing    

End Sub

public void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "DOCX Converter Developer Evaluation";

    const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

    const string AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

    // Declare a new cdintfex object if it does not exist in the form.

    CDIntfEx.CDIntfEx DOCX = 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

    DOCX.DriverInit(AMYUNIPRINTERNAME);

 

    // The SetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter();

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode);

 

    // Set SendSmtpMail

    DOCX.SendSmtpMail("YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer

    // to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter();

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd();

 

    // Destroy DOCX object

    DOCX = null;    

}

// DOCX Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment(lib, "CDIntf.lib")

 

using namespace std;

 

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "DOCX Converter Developer Evaluation"

    #define strActivationCode "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    #define AMYUNIPRINTERNAME "Amyuni DOCX 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 DOCX = DriverInit(AMYUNIPRINTERNAME);

 

    // The CDISetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    CDISetDefaultPrinter(DOCX);

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    EnablePrinter(DOCX, strLicenseTo, strActivationCode);

 

    // Set SendSmtpMail

    SendSmtpMail("YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer 

    // to the printer that was the default before the call to SetDefaultPrinter.

    RestoreDefaultPrinter(DOCX);

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DriverEnd(DOCX);  

 

    // Destroy DOCX object

    DOCX = NULL;    

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

 

public class Sample {

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "DOCX Converter Developer Evaluation";

        String strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

        String AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

        // Declare a new cdintfex object if it does not exist in the form.

        ActiveXComponent docx = 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(docx,"DriverInit",AMYUNIPRINTERNAME);

 

        // The SetDefaultPrinter function sets the system default printer to the one

        // initialized by the DriverInit functions.

        Dispatch.call(docx,"SetDefaultPrinter");

 

        // The EnablePrinter() method needs to be called right before each print job. 

        // Calling the EnablePrinter() method will start a 20 second time-out value

        Dispatch.call(docx,"EnablePrinter", strLicenseTo, strActivationCode); 

 

        // Set SendSmtpMail

        Dispatch.call(docx,"SendSmtpMail", "YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

        // The RestoreDefaultPrinter function resets the system default printer 

        // to the printer that was the default before the call to SetDefaultPrinter.

        Dispatch.call(docx,"RestoreDefaultPrinter"); 

 

        // This function will simply detach from an existing printer because the handle was created using DriverInit

        Dispatch.call(docx,"DriverEnd");

 

        // Destroy DOCX object

        docx = null;        

    }

}

# Constants for Activation codes

$strLicenseTo  =  "DOCX Converter Developer Evaluation"

$strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

$AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

#Declare a new cdintfex object if it does not exist in the form.

$DOCX = 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,$DOCX,$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,$DOCX,$null)

 

#The EnablePrinter() method needs to be called right before each print job. 

#Calling the EnablePrinter() method will start a 20 second time-out value

[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, @($strLicenseTo, $strActivationCode))

 

#Set SendSmtpMail

[System.__ComObject].InvokeMember('SendSmtpMail', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, 

    @("YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

                "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx"))

 

#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,$DOCX,$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,$DOCX,$null)

 

#Destroy DOCX object

$DOCX = $null

' Constants for Activation codes

Const strLicenseTo = "DOCX Converter Developer Evaluation"

Const strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

Const AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

' Declare a new cdintfex object

Dim DOCX

Set DOCX = 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

DOCX.DriverInit AMYUNIPRINTERNAME

 

' The SetDefaultPrinter function sets the system default printer to the one

' initialized by the DriverInit functions.

DOCX.SetDefaultPrinter

 

' The EnablePrinter() method needs to be called right before each print job.

' Calling the EnablePrinter() method will start a 20 second time-out value

DOCX.EnablePrinter strLicenseTo, strActivationCode

 

' Set SendSmtpMail

DOCX.SendSmtpMail "YOUR_SMTP_SERVER", 25, "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",_

                 "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",_

                 "c:\temp\temp1.docx;document1.docx;c:\temp\temp2.docx;document2.docx"

 

' The RestoreDefaultPrinter function resets the system default printer

' to the printer that was the default before the call to SetDefaultPrinter.

DOCX.RestoreDefaultPrinter

 

' This function will simply detach from an existing printer because the handle was created using DriverInit

DOCX.DriverEnd

 

' Destroy DOCX object

Set DOCX = Nothing

 

Example Secured SMTP

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "DOCX Converter Developer Evaluation"

    Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    Const AMYUNIPRINTERNAME As String = "Amyuni DOCX Converter"

 

    ' Declare a new cdintfex object if it does not exist in the form.

    Dim DOCX 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

    DOCX.DriverInit(AMYUNIPRINTERNAME)

 

    ' The SetDefaultPrinter function sets the system default printer to the one

    ' initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter()

 

    ' The EnablePrinter() method needs to be called right before each print job. 

    ' Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode)

 

    ' Set SendSmtpMail

    DOCX.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 DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx")

 

    ' The RestoreDefaultPrinter function resets the system default printer 

    ' to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter()

 

    ' This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd()

 

    ' Destroy DOCX object

    DOCX = Nothing    

End Sub

public void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "DOCX Converter Developer Evaluation";

    const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

    const string AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

    // Declare a new cdintfex object if it does not exist in the form.

    CDIntfEx.CDIntfEx DOCX = 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

    DOCX.DriverInit(AMYUNIPRINTERNAME);

 

    // The SetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter();

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode);

 

    // Set SendSmtpMail

    DOCX.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 DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer

    // to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter();

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd();

 

    // Destroy DOCX object

    DOCX = null;    

}

// DOCX Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment(lib, "CDIntf.lib")

 

using namespace std;

 

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "DOCX Converter Developer Evaluation"

    #define strActivationCode "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    #define AMYUNIPRINTERNAME "Amyuni DOCX 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 DOCX = DriverInit(AMYUNIPRINTERNAME);

 

    // The CDISetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    CDISetDefaultPrinter(DOCX);

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    EnablePrinter(DOCX, strLicenseTo, strActivationCode);

 

    // 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 DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer 

    // to the printer that was the default before the call to SetDefaultPrinter.

    RestoreDefaultPrinter(DOCX);

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DriverEnd(DOCX);

 

    // Destroy DOCX object

    DOCX = NULL;    

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

 

public class Sample {

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "DOCX Converter Developer Evaluation";

        String strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

        String AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

        // Declare a new cdintfex object if it does not exist in the form.

        ActiveXComponent docx = 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(docx,"DriverInit",AMYUNIPRINTERNAME);

 

        // The SetDefaultPrinter function sets the system default printer to the one

        // initialized by the DriverInit functions.

        Dispatch.call(docx,"SetDefaultPrinter");

 

        // The EnablePrinter() method needs to be called right before each print job. 

        // Calling the EnablePrinter() method will start a 20 second time-out value

        Dispatch.call(docx,"EnablePrinter", strLicenseTo, strActivationCode); 

 

        // Set SendSmtpMail

        Dispatch.call(docx,"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 DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

        // The RestoreDefaultPrinter function resets the system default printer 

        // to the printer that was the default before the call to SetDefaultPrinter.

        Dispatch.call(docx,"RestoreDefaultPrinter"); 

 

        // This function will simply detach from an existing printer because the handle was created using DriverInit

        Dispatch.call(docx,"DriverEnd");

 

        // Destroy DOCX object

        docx = null;        

    }

}

# Constants for Activation codes

$strLicenseTo  =  "DOCX Converter Developer Evaluation"

$strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

$AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

#Declare a new cdintfex object if it does not exist in the form.

$DOCX = 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,$DOCX,$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,$DOCX,$null)

 

#The EnablePrinter() method needs to be called right before each print job. 

#Calling the EnablePrinter() method will start a 20 second time-out value

[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, @($strLicenseTo, $strActivationCode))

 

#Set SendSmtpMail

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

    @("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 DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx"))

 

#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,$DOCX,$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,$DOCX,$null)

 

#Destroy DOCX object

$DOCX = $null

' Constants for Activation codes

Const strLicenseTo = "DOCX Converter Developer Evaluation"

Const strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

Const AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

' Declare a new cdintfex object

Dim DOCX

Set DOCX = 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

DOCX.DriverInit AMYUNIPRINTERNAME

 

' The SetDefaultPrinter function sets the system default printer to the one

' initialized by the DriverInit functions.

DOCX.SetDefaultPrinter

 

' The EnablePrinter() method needs to be called right before each print job.

' Calling the EnablePrinter() method will start a 20 second time-out value

DOCX.EnablePrinter strLicenseTo, strActivationCode

 

' Set SendSmtpMail

DOCX.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 DOCX format.",_

                 "c:\temp\temp1.docx;document1.docx;c:\temp\temp2.docx;document2.docx"

 

' The RestoreDefaultPrinter function resets the system default printer

' to the printer that was the default before the call to SetDefaultPrinter.

DOCX.RestoreDefaultPrinter

 

' This function will simply detach from an existing printer because the handle was created using DriverInit

DOCX.DriverEnd

 

' Destroy DOCX object

Set DOCX = Nothing

 

Example Secured SMTP using Port flags

<Flags()>

Public Enum PORT_FLAGS As Integer

    SMTP_SECUREPORT = &H80000000

    SMTP_USESTARTTLS = &H40000000

    SMTP_FORCESECURESMTP = &H20000000

End Enum

 

Public Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "DOCX Converter Developer Evaluation"

    Const strActivationCode As String = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    Const AMYUNIPRINTERNAME As String = "Amyuni DOCX Converter"

 

    ' Declare a new cdintfex object if it does not exist in the form.

    Dim DOCX 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

    DOCX.DriverInit(AMYUNIPRINTERNAME)

 

    ' The SetDefaultPrinter function sets the system default printer to the one

    ' initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter()

 

    ' The EnablePrinter() method needs to be called right before each print job. 

    ' Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode)

 

    ' Set SendSmtpMail

    DOCX.SendSmtpMailEx("YOUR_SMTP_SERVER", PORT_FLAGS.SMTP_SECUREPORT + 8025, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

                "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx")

 

    ' The RestoreDefaultPrinter function resets the system default printer 

    ' to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter()

 

    ' This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd()

 

    ' Destroy DOCX object

    DOCX = Nothing    

End Sub

[Flags()]

public enum PORT_FLAGS

{

    SMTP_SECUREPORT = unchecked((int)0x80000000),

    SMTP_USESTARTTLS = 0x40000000,

    SMTP_FORCESECURESMTP = 0x20000000,

}

 

public void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "DOCX Converter Developer Evaluation";

    const string strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

    const string AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

    // Declare a new cdintfex object if it does not exist in the form.

    CDIntfEx.CDIntfEx DOCX = 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

    DOCX.DriverInit(AMYUNIPRINTERNAME);

 

    // The SetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    DOCX.SetDefaultPrinter();

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    DOCX.EnablePrinter(strLicenseTo, strActivationCode);

 

    // Set SendSmtpMail

    DOCX.SendSmtpMailEx("YOUR_SMTP_SERVER",(int)PORT_FLAGS.SMTP_SECUREPORT + 8025, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer

    // to the printer that was the default before the call to SetDefaultPrinter.

    DOCX.RestoreDefaultPrinter();

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DOCX.DriverEnd();

 

    // Destroy DOCX object

    DOCX = null;    

}

// DOCX Converter Cpp.cpp : Defines the entry point for the console application.

// 

 

#include <Windows.h>

#include <string>

#include <iostream>

#include "CdIntf.h"

#pragma comment(lib, "CDIntf.lib")

 

#define SMTP_SECUREPORT          0x80000000   // if port number has this flag set, indicates the need for a secure connection

#define SMTP_USESTARTTLS         0x40000000   // use the STARTTLS protocol

#define SMTP_FORCESECURESMTP     0x20000000   // do not communicate unless secure communications can be established

 

using namespace std;

 

 

int main()

{

     // Constants for Activation codes

    #define strLicenseTo  "DOCX Converter Developer Evaluation"

    #define strActivationCode "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

    #define AMYUNIPRINTERNAME "Amyuni DOCX 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 DOCX = DriverInit(AMYUNIPRINTERNAME);

 

    // The CDISetDefaultPrinter function sets the system default printer to the one

    // initialized by the DriverInit functions.

    CDISetDefaultPrinter(DOCX);

 

    // The EnablePrinter() method needs to be called right before each print job. 

    // Calling the EnablePrinter() method will start a 20 second time-out value

    EnablePrinter(DOCX, strLicenseTo, strActivationCode);

 

    // Set SendSmtpMail

    SendSmtpMailEx("YOUR_SMTP_SERVER",(int)(SMTP_SECUREPORT + 8025), "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

    // The RestoreDefaultPrinter function resets the system default printer 

    // to the printer that was the default before the call to SetDefaultPrinter.

    RestoreDefaultPrinter(DOCX);

 

    // This function will simply detach from an existing printer because the handle was created using DriverInit

    DriverEnd(DOCX);

 

    // Destroy DOCX object

    DOCX = NULL;    

 

    return 0;

}

package Example;

 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

 

public class Sample {

 

     public enum PORT_FLAGS

     {

         SMTP_SECUREPORT(0x80000000),

         SMTP_USESTARTTLS(0x40000000),

         SMTP_FORCESECURESMTP(0x20000000);

         public int value;

         public PORT_FLAGS(int value)

         {

             this.value = value;

         }

         public Object value(){

             return value;

         }        }

    public static void main(String[] args)

    {

        // Constants for Activation codes

        String strLicenseTo  = "DOCX Converter Developer Evaluation";

        String strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190";

        String AMYUNIPRINTERNAME = "Amyuni DOCX Converter";

 

        // Declare a new cdintfex object if it does not exist in the form.

        ActiveXComponent docx = 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(docx,"DriverInit",AMYUNIPRINTERNAME);

 

        // The SetDefaultPrinter function sets the system default printer to the one

        // initialized by the DriverInit functions.

        Dispatch.call(docx,"SetDefaultPrinter");

 

        // The EnablePrinter() method needs to be called right before each print job. 

        // Calling the EnablePrinter() method will start a 20 second time-out value

        Dispatch.call(docx,"EnablePrinter", strLicenseTo, strActivationCode); 

 

        // Set SendSmtpMail

        Dispatch.call(docx,"SendSmtpMailEx", "YOUR_SMTP_SERVER", PORT_FLAGS.SMTP_SECUREPORT.value + 8025, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

        "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

        "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx");

 

        // The RestoreDefaultPrinter function resets the system default printer 

        // to the printer that was the default before the call to SetDefaultPrinter.

        Dispatch.call(docx,"RestoreDefaultPrinter"); 

 

        // This function will simply detach from an existing printer because the handle was created using DriverInit

        Dispatch.call(docx,"DriverEnd");

 

        // Destroy DOCX object

        docx = null;        

    }

}

$PORT_FLAGS = @{

    SMTP_SECUREPORT = 0x80000000

    SMTP_USESTARTTLS = 0x40000000

    SMTP_FORCESECURESMTP = 0x20000000

}

 

# Constants for Activation codes

$strLicenseTo  =  "DOCX Converter Developer Evaluation"

$strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

$AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

#Declare a new cdintfex object if it does not exist in the form.

$DOCX = 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,$DOCX,$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,$DOCX,$null)

 

#The EnablePrinter() method needs to be called right before each print job. 

#Calling the EnablePrinter() method will start a 20 second time-out value

[System.__ComObject].InvokeMember('EnablePrinter', [System.Reflection.BindingFlags]::InvokeMethod,$null,$DOCX, @($strLicenseTo, $strActivationCode))

 

#Set SendSmtpMail

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

    @("YOUR_SMTP_SERVER", $PORT_FLAGS::SMTP_SECUREPORT + 8025, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",

                "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",

                "c:\\temp1.docx;document1.docx;c:\\temp2.docx;document2.docx"))

 

#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,$DOCX,$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,$DOCX,$null)

 

#Destroy DOCX object

$DOCX = $null

' PORT_FLAGS

Const SMTP_SECUREPORT = -2147483648

Const SMTP_USESTARTTLS = 1073741824‬

Const SMTP_FORCESECURESMTP = 536870912

 

' Constants for Activation codes

Const strLicenseTo = "DOCX Converter Developer Evaluation"

Const strActivationCode = "07EFCDAB010001002EE718DAABD90353AA8141F60B6762C695F4D5BA97F516CBE3EB407DC717EC1D28DE39A61F1ACE26924C99AFB190"

Const AMYUNIPRINTERNAME = "Amyuni DOCX Converter"

 

' Declare a new cdintfex object

Dim DOCX

Set DOCX = 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

DOCX.DriverInit AMYUNIPRINTERNAME

 

' The SetDefaultPrinter function sets the system default printer to the one

' initialized by the DriverInit functions.

DOCX.SetDefaultPrinter

 

' The EnablePrinter() method needs to be called right before each print job.

' Calling the EnablePrinter() method will start a 20 second time-out value

DOCX.EnablePrinter strLicenseTo, strActivationCode

 

' Set SendSmtpMail

DOCX.SendSmtpMailEx "YOUR_SMTP_SERVER", SMTP_SECUREPORT + 8025, "support@amyuni.com", "monPassword", "support@amyuni.com", "info@amyuni.com", "sales@amyuni.com", "",_

                 "Testing email capabilities", "Please find attached the requested document\nin DOCX format.",_

                 "c:\temp\temp1.docx;document1.docx;c:\temp\temp2.docx;document2.docx"

 

' The RestoreDefaultPrinter function resets the system default printer

' to the printer that was the default before the call to SetDefaultPrinter.

DOCX.RestoreDefaultPrinter

 

' This function will simply detach from an existing printer because the handle was created using DriverInit

DOCX.DriverEnd

 

' Destroy DOCX object

Set DOCX = Nothing