SendMail (BizTalk Server Sample)
The SendMail sample demonstrates how you can use the Simple Mail Transfer Protocol (SMTP) adapter to send e-mail messages from within a Microsoft BizTalk Server orchestration. Dynamic information used to send the e-mail messages is retrieved from an XML message using property promotion functionality.
This sample sends an e-mail message using information obtained from properties promoted out of an incoming XML purchase order (PO) message, using the following sequence of steps:
- The BizTalk Server orchestration retrieves an input XML PO message.
- The BizTalk Server orchestration promotes the PONumber and Email properties for easier access in the future.
- The BizTalk Server orchestration uses the values of the promoted properties to set the destination address of the dynamic send port and to set the subject of the e-mail message.
- The BizTalk Server orchestration sends the constructed e-mail message through the SMTP adapter.
Note For important information about all samples in this SDK, see Samples.
To download the updated BizTalk Server 2004 SDK, go to http://go.microsoft.com/fwlink/?LinkId=24723.
Location in SDK
The following table shows the files in this sample and describes their purpose.
|AssemblyInfo.cs, SendMail.btproj, SendMail.sln||Provides project, solution, and assembly information files for this sample.|
|Cleanup.bat||Undeploys assemblies and removes them from the global assembly cache (GAC); removes send and receive ports; removes Microsoft Internet Information Services (IIS) virtual directories as needed.|
|PropertySchema.xsd, PurchaseOrder.xsd||Provides schemas for the properties that you want to promote, and for the XML PO message, respectively.|
|ReceiveSend.odx||Provides a BizTalk Server orchestration that processes the incoming XML PO message and sends an e-mail message based on information in the message.|
|SendMailInput.xml||Contains a sample input file with a PO specified using XML.|
|Setup.bat||Builds and initializes this sample.
To Build and Initialize This Sample
Use the following procedure to build and initialize the SendMail sample.
- In a command window, navigate to the following folder:
- Run the file Setup.bat, which performs the following actions:
- Creates the following input folder for this sample:
- Compiles the Visual Studio .NET project for this sample.
- Starts the BizTalk Server orchestration.
Note You should confirm that BizTalk did not report any errors during the build and initialization process before attempting to run this sample.
Note If you choose to open and build the project in this sample without running the file Setup.bat, you must first create a strong name key pair using the .NET Framework Strong Name Utility (sn.exe). Use this key pair to sign the resulting assembly.
Note To undo changes made by Setup.bat, run Cleanup.bat and delete all receive and send ports prefixed with SendMail_18.104.22.168_Microsoft.Samples.BizTalk.SendMail. You must run Cleanup.bat before running Setup.bat a second time.
- Creates the following input folder for this sample:
- Using BizTalk Explorer, locate the receive port prefixed by SendMail_22.214.171.124_Microsoft.Samples.BizTalk.SendMail. Update the receive location for this receive port to point to a directory on your file system to use as the input location.
- Using a program such as Notepad, modify the file SendMailInput.xml so that the Email element specifies a legitimate e-mail address at which you want to receive the e-mail message generated by this sample.
- Click Start, point to Programs, point to Microsoft BizTalk Server 2004, and then click BizTalk Server Administration.
- In the BizTalk Server Administration console, expand the Microsoft BizTalk Server 2004 (Local) tree in the left pane, and then navigate to the Adapters folder.
- Expand the Adapters folder, expand the SMTP node, and then click the Send Handlers node.
- In the BizTalkServerApplication properties dialog box, on the Properties tab, provide appropriate values for the SMTP server name and From (Email address) properties.
These values will be used to construct the From e-mail address for any e-mail messages sent through this SMTP adapter.
Note If you need to authenticate with your SMTP server, you must ensure that the From e-mail address belongs to the same account that you use for authentication.
- Stop and then restart the BizTalk service (BizTalkServerApplication) so that the orchestration will adopt these changes.
To Run This Sample
Use the following procedure to run the SendMail sample.
- Put a copy of the modified file SendMailInput.xml into the input folder
- Observe the arrival of an e-mail message to the e-mail address you specified in the previous procedure.
If you update a send port or receive location using the BizTalk Explorer object model or a Windows Management Instrumentation (WMI) script, the Receive Port Properties and Send Port Properties property pages in BizTalk Explorer will display an incorrect Address (URI). The Address (URI) used internally is the Address (URI) set by the script, so the script works as expected. To update the property pages to display the correct Address (URI), update the Address (URI) field in BizTalk Explorer with the new value. Additional information and the instructions for completing this step will be provided in the updated BizTalk Server
See Alsohttp://go.microsoft.com/fwlink/?linkid=20616.Copyright © 2004 Microsoft Corporation.
All rights reserved.