SMTP Settings

These functions are used to set the server address, port number, username and password of the server used to send e-mails. These parameters are needed only when sending e-mails through direct SMTP without the use of MAPI.

 

Syntax

ActiveX:

System.String SmtpServer
System.Int32 SmtpPort
System.String SmtpUsername
System.String SmtpPassword

DLL:

int SetSmtpServer(HANDLE hPrinter, LPCSTR szSmtpServer)
int SetSmtpPort(HANDLE hPrinter, long lSmtpPort)
int SetSmtpUsername(HANDLE hIntf, LPCSTR szSmtpUsername)
int SetSmtpPassword(HANDLE hIntf, LPCSTR szSmtpPassword)

 

Parameters

SmtpServer, szSmtpServer

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

SmtpPort, lSmtpPort

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

SmtpUsername, szSmtpUsername

User name for the SMTP server.

SmtpPassword, szSmtpPassword

Password for the SMTP server.

hPrinter

Handle to printer returned by any of the DriverInit function calls.

 

Return Value

The functions will return 1 if successful, 0 otherwise.

 

Remarks

E-mails can be sent using either MAPI compliant e-mail systems, or directly using SMTP protocol without the use of any installed e-mail client.

 

Member of CDIntfEx.CDIntfEx.

 

Example

<Flags()>

Public Enum EMAILOPTIONS As Integer

    SMO_PROMPT_RECIPIENT = 2 ' prompt before sending MAPI emails

    SMO_SMTP_MAIL = 4 ' send by SMTP and not MAPI

End Enum

 

<Flags()>

Public Enum acFileNameOptions As Integer

    ' Please check FileNameOptions for the complete flags version

    NoPrompt = &H1

    UseFileName = &H2

    Concatenate = &H4

    DisableCompression = &H8

    EmbedFonts = &H10

    BroadcastMessages = &H20

    SendByEmail = &H800

End Enum

 

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

 

    ' Resulting PDF document stored here

    PDF.DefaultDirectory = "C:\Temp"

 

    ' Set Printer options

    PDF.FileNameOptionsEx = acFileNameOptions.NoPrompt Or acFileNameOptions.SendByEmail

 

    ' Set email parameters

    PDF.EmailFieldTo = "info@amyuni.com"

    PDF.EmailFieldFrom = "support@amyuni.com"

    PDF.EmailSubject = "Testing email capabilities"

    PDF.EmailMessage = "Please find attached the requested document\nin RTF format."

    PDF.EmailOptions = EMAILOPTIONS.SMO_SMTP_MAIL

 

    ' Set SMTP paramters

    PDF.SmtpServer = "smtp.amyuni.com"

    PDF.SmtpPort = 25

    PDF.SmtpUsername = "amyuni"

    PDF.SmtpPassword = "123456"

 

    ' The BatchConvert method converts a number of files to PDF.

    PDF.BatchConvert("C:\Temp\*.docx")

 

    ' 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

    PDF = Nothing    

End Sub

[Flags]

public enum EMAILOPTIONS

{

    SMO_PROMPT_RECIPIENT = 2, // prompt before sending MAPI emails

    SMO_SMTP_MAIL = 4 // send by SMTP and not MAPI

}

[Flags]

public enum acFileNameOptions

{

    // Please check FileNameOptions for the complete flags version

    NoPrompt = 0x00000001,

    UseFileName = 0x00000002,

    Concatenate = 0x00000004,

    DisableCompression = 0x00000008,

    EmbedFonts = 0x00000010,

    BroadcastMessages = 0x00000020,

    SendByEmail = 0x00000800

}

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

 

    // Resulting PDF document stored here

    PDF.DefaultDirectory = "C:\temp";

 

    // Set Printer options

    PDF.FileNameOptionsEx = (int)(acFileNameOptions.NoPrompt | acFileNameOptions.SendByEmail);

 

    // Set email parameters

    PDF.EmailFieldTo = "info@amyuni.com";

    PDF.EmailFieldFrom = "support@amyuni.com";

    PDF.EmailSubject = "Testing email capabilities";

    PDF.EmailMessage = "Please find attached the requested document\nin RTF format.";

    PDF.EmailOptions = (int)EMAILOPTIONS.SMO_SMTP_MAIL;

 

    // Set SMTP paramters

    PDF.SmtpServer = "smtp.amyuni.com";

    PDF.SmtpPort = 25;

    PDF.SmtpUsername = "amyuni";

    PDF.SmtpPassword = "123456";

 

    // The BatchConvert method converts a number of files to PDF.

    PDF.BatchConvert("C:/Temp/*.docx");

 

    // 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 <iostream>

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

 

    // Resulting PDF document stored here

    SetDefaultDirectory(PDF, "C:/Temp");

 

    // Set Printer options

    SetFileNameOptions(PDF, NoPrompt | SendByEmail);

 

    // Set email parameters

    SetEmailFieldTo(PDF, "info@amyuni.com");

    SetEmailFieldFrom(PDF, "support@amyuni.com");

    SetEmailSubject(PDF, "Testing email capabilities");

    SetEmailMessage(PDF, "Please find attached the requested document\nin RTF format.");

    SetEmailOptions(PDF, SMO_SMTP_MAIL);

 

    // Set SMTP paramters

    SetSmtpServer(PDF, "smtp.amyuni.com");

    SetSmtpPort(PDF, 25);

    SetSmtpUsername(PDF, "amyuni");

    SetSmtpPassword(PDF, "123456");

 

    // The BatchConvert method converts a number of files to PDF.

    BatchConvertEx(PDF, "C:/Temp/*.docx");

 

    // 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 EMAILOPTIONS

    {

        // Please check FileNameOptions for the complete flags version

        SMO_PROMPT_RECIPIENT(2),

        SMO_SMTP_MAIL(4);

        private int value;

        private EMAILOPTIONS(int value)

        {

            this.value = value;

        }

        public Object value(){

            return value;

        }

    }

    public enum acFileNameOptions

    {

        // Please check FileNameOptions for the complete flags version

        NoPrompt(0x00000001),

        UseFileName(0x00000002),

        Concatenate(0x00000004),

        DisableCompression(0x00000008),

        EmbedFonts(0x00000010),

        BroadcastMessages(0x00000020),

        SendByEmail(0x00000800);

        private int value;

        private acFileNameOptions(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);

 

        // Resulting PDF document stored here

        Dispatch.put(pdf,"DefaultDirectory","C:\temp");

 

        // Set Printer options

        Dispatch.put(pdf,"FileNameOptionsEx",acFileNameOptions.NoPrompt.value | acFileNameOptions.SendByEmail.value );

 

        // Set email parameters

        Dispatch.put(pdf,"EmailFieldTo", "info@amyuni.com");

        Dispatch.put(pdf,"EmailFieldFrom", "support@amyuni.com");

        Dispatch.put(pdf,"EmailSubject", "Testing email capabilities");

        Dispatch.put(pdf,"EmailMessage", "Please find attached the requested document\nin RTF format.");

        Dispatch.put(pdf,"EmailOptions", EMAILOPTIONS.SMO_SMTP_MAIL.value);

 

        // Set SMTP paramters

        Dispatch.put(pdf,"SmtpServer", "smtp.amyuni.com");

        Dispatch.put(pdf,"SmtpPort", 25);

        Dispatch.put(pdf,"SmtpUsername", "amyuni");

        Dispatch.put(pdf,"SmtpPassword", "123456");

 

        // The BatchConvert method converts a number of files to PDF.

        Dispatch.call(pdf,"BatchConvert","C:\temp\\*.docx");

 

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

    }

}

$EMAILOPTIONS = @{    

    SMO_PROMPT_RECIPIENT = 2 # prompt before sending MAPI emails

    SMO_SMTP_MAIL = 4 # send by SMTP and not MAPI

}

 

$acFileNameOptions = @{

    NoPrompt = 0x00000001

    UseFileName = 0x00000002

    Concatenate = 0x00000004

    DisableCompression = 0x00000008

    EmbedFonts = 0x00000010

    BroadcastMessages = 0x00000020

    SendByEmail = 0x00000800

# Please check FileNameOptions for the complete flags version

 

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

 

# Resulting PDF document stored here

[System.__ComObject].InvokeMember('DefaultDirectory', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF,"C:/Temp") 

 

# Set Printer options

[System.__ComObject].InvokeMember('FileNameOptionsEx', [System.Reflection.BindingFlags]::SetProperty,$null,$PDF, 

        $acFileNameOptions::NoPrompt -bOr $acFileNameOptions::SendByEmail)

 

# Set email parameters

[System.__ComObject].InvokeMember('EmailFieldTo', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "info@amyuni.com")

[System.__ComObject].InvokeMember('EmailFieldFrom', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "support@amyuni.com")

[System.__ComObject].InvokeMember('EmailSubject', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "Testing email capabilities")

[System.__ComObject].InvokeMember('EmailMessage', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "Please find attached the requested document\nin RTF format.")

[System.__ComObject].InvokeMember('EmailOptions', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, $EMAILOPTIONS::SMO_SMTP_MAIL)

 

# Set SMTP paramters

[System.__ComObject].InvokeMember('SmtpServer', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "smtp.amyuni.com")

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

[System.__ComObject].InvokeMember('SmtpUsername', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "amyuni")

[System.__ComObject].InvokeMember('SmtpPassword', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "123456")

 

# The BatchConvert method converts a number of files to PDF.

[System.__ComObject].InvokeMember('BatchConvert', [System.Reflection.BindingFlags]::InvokeMethod,$null,$PDF, "C:\Temp\*.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,$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

' EmailOptions constants

Const SMO_PROMPT_RECIPIENT = 2 ' prompt before sending MAPI emails

Const SMO_SMTP_MAIL = 4 ' send by SMTP and not MAPI

 

' FileNameOptions constants

' Please check FileNameOptions for the complete flags version

Const NoPrompt = &H1

Const UseFileName = &H2

Const Concatenate = &H4

Const DisableCompression = &H8

Const EmbedFonts = &H10

Const BroadcastMessages = &H20

Const PrintWatermark = &H40

Const MultilingualSupport = &H80

Const EncryptDocument = &H100

Const FullEmbed = &H200

 

' 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

 

' Resulting PDF document stored here

PDF.DefaultDirectory = "C:\Temp"

 

' Set Printer options

PDF.FileNameOptionsEx = NoPrompt Or SendByEmail

 

' 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 email parameters

PDF.EmailFieldTo = "info@amyuni.com"

PDF.EmailFieldFrom = "support@amyuni.com"

PDF.EmailSubject = "Testing email capabilities"

PDF.EmailMessage = "Please find attached the requested document\nin PDF format."

PDF.EmailOptions = SMO_SMTP_MAIL

 

' Set SMTP paramters

PDF.SmtpServer = "smtp.amyuni.com"

PDF.SmtpPort = 25

PDF.SmtpUsername = "amyuni"

PDF.SmtpPassword = "123456"

 

' The BatchConvert method converts a number of files to PDF.

PDF.BatchConvert "C:\Temp\*.docx"

 

' 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