How to Programmatically Change the Subject for SMTP Transport (283234)
The information in this article applies to:
- Microsoft BizTalk Server 2000
This article was previously published under Q283234 SUMMARY
When you use SMTP as a Primary Transport, the default subject line that is sent with the message contains the interchange GUID. You can manually modify the subject line by opening the Channel that is bound to the port and overriding the properties by clicking the Advanced button at the end of the Channel Wizard. This article describes how to programmatically change the subject line for a port that is using SMTP as its Primary Transport.
MORE INFORMATION
The following code snippet is a Visual Basic Script example that demonstrates how to change the subject line for an SMTP Primary Transport.
Save the follow segment of code to a file named SMTPSubjectChange.vbs: NOTE: The lines of code that are in uppercase need to be changed to point to a valid channel and port in your environment.
Const BIZTALK_CONFIGDATA_TYPE_PRIMARYTRANSPORT = 0
Const BIZTALK_TRANSPORT_TYPE_SMTP = 8
Dim objConfig ' BizTalkConfig Interface
Dim objChannel ' BizTalkChannel Interface
Dim objPort ' BizTalkPort Interface
Dim objDic ' CDictionary Interface
' Create the two objects that are needed to change the transport
Set objConfig = CreateObject("BizTalk.BizTalkConfig.1")
Set objDic = CreateObject("Commerce.Dictionary")
' Call the Create methods that return the channel and port objects.
Set objChannel = objConfig.CreateChannel
Set objPort = objConfig.CreatePort
' Load the channel and port that utilize the SMTP transport and retrieve the handle to the port
objChannel.LoadByName ("XMLFromSource")
objPort.LoadByName ("XMLToFlat")
portID = objPort.Handle
' Call GetConfigData passing the port handle, which will result in a Dictionary object being returned.
Set objDic = objChannel.GetConfigData(BIZTALK_CONFIGDATA_TYPE_PRIMARYTRANSPORT, portID, BIZTALK_TRANSPORT_TYPE_SMTP)
' Once the dictionary object is returned, we can change the subject and save the data back to the port.
objDic.subject = "this is a test"
Call objChannel.SetConfigData(BIZTALK_CONFIGDATA_TYPE_PRIMARYTRANSPORT, portID, objDic)
objChannel.Save
Set objConfig = Nothing
Set objChannel = Nothing
Set objPort = Nothing
Set objDic = Nothing
When the sample has been executed, open the channel and view the Subject property in the Advanced properties.
To manually view the Subject property, perform the following steps:
- Open the BizTalk Messaging Manager.
- Click Channels, and then click Search Now.
- Double-click the channel in question.
- Click Next five times, click Advanced, and then click Properties.
IMPORTANT: Microsoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbhowto kbProgramming KB283234 |
---|
|