1. Problem
You need to send a message from BizTalk with the Simple Mail Transport Protocol (SMTP).
2. Solution
This example configures a
BizTalk send port using the SMTP adapter to send a message to a single
email recipient. The following steps outline how to configure the SMTP
adapter:
NOTE
This recipe demonstrates how
to create a static SMTP port. In many cases, you will need to specify
dynamic values for an e-mail, including message content, recipients,
subject line, and so on. All of this can be set dynamically using an
orchestration and a dynamic send port.
If BizTalk needs to send each message to a different email address, use a dynamic port from an orchestration.
Open the BizTalk Administration Console.
Expand the BizTalk Server group, select the appropriate BizTalk application, and select the Send Ports folder.
Right-click the Send Ports folder, and select New→Static One-Way Send Port to open the Send Port Properties dialog box. Give the Send Port a name.
Within the Transport section of the General tab, select SMTP from the Type drop-down list, as shown in Figure 1.
Click the Configure button to open the SMTP Transport Properties dialog box.
On the General tab, enter the message recipient's e-mail address and the e-mail message subject, as shown in Figure 2.
Additionally, request delivery and read receipts to get a notification
e-mail when the message recipient receives or marks the message as read.
The
settings on the Compose tab provide three options for specifying the
message body. First, the message body may directly contain the sent
message. Second, you can set the message to a fixed value, as shown in Figure 3. Third, BizTalk can retrieve the message from a file location. Set these options as necessary.
The
Attachments tab allows you to configure the different ways BizTalk can
include attachments. BizTalk can include the message being sent with the
SMTP adapter as an attachment or include an external file as an
attachment, as shown in Figure 4. Set these options as necessary.
The
Handler Override tab contains SMTP configuration settings such as the
SMTP server name, the From address used when sending email messages, and
authentication settings. Instead of setting these configuration values
for each send port using the SMTP transport, all SMTP send ports can
share configuration values for the SMTP handler. Only change these
values from the default settings if you need to override the default
SMTP handler configuration.
NOTE
This recipe demonstrates
how to create a static SMTP port. In many cases, you will need to
specify dynamic values for an e-mail, including message content,
recipients, subject line, and so on. All of this can be set dynamically
using an orchestration and a dynamic send port.
3. How It Works
BizTalk can only send email
messages with the SMTP adapter. To receive a message via e-mail, you can
use the POP3 adapter. Of course, in all cases, you can write a custom
adapter or implement a third-party adapter if available.
The security settings of some
SMTP servers disallow impersonation. Under these circumstances, the
From address in an e-mail must match the account credentials provided to
the SMTP server. The SMTP server must have an e-mail account created
specifically for the credentials provided by BizTalk. For example, when
specifying process account (NTLM) authentication, the identity of the
BizTalk host instance must also have a valid e-mail address. If the From
address does not match the e-mail address of the host instance
identity, the e-mail will not be sent. You can configure settings on the
adapter to be used by all send ports via the adapter. Configure the
SMTP handler with properties that any SMTP send port can reuse with the
following steps:
Connect to the BizTalk group in the BizTalk Administration Console, expand the Platform Settings folder, and expand the Adapters folder. Select the SMTP adapter.
Right-click the host appearing in the right pane of the BizTalk Administration Console, and select Properties.
Click the Properties button in the SMTP Transport Properties dialog box.
Set the default configuration values for the SMTP adapter. See Figure 5.
You have three handler configuration options for authenticating with the SMTP server, as shown in Table 1. SMTP send ports have a fourth default authentication option, which specifies to use the handler configuration setting.
Table 1. SMTP Handler Authentication Options
Authentication Option | Description |
---|
Basic Authentication | Specifies
specific credentials to authenticate with the SMTP server. BizTalk may
pass these credentials over the network in clear text. |
Do Not Authenticate | BizTalk provides no authentication credentials when sending an email message via SMTP. |
Process Account (NTLM) | The adapter uses the host instance identity to authenticate with the SMTP server. |
Finally,
when setting SMTP values on a dynamic port from within an
orchestration, use a message assignment shape to set the properties to
the variable values. For example, if you want to set the e-mail body
text to a dynamic value, the message assignment would look like that
shown in Figure 6.