Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to Programmatically Change the Subject for SMTP Transport


View products that this article applies to.

This article was previously published under Q283234

↑ Back to the top


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.

↑ Back to the top


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:
1.Open the BizTalk Messaging Manager.
2.Click Channels, and then click Search Now.
3.Double-click the channel in question.
4.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:

↑ Back to the top


Keywords: KB283234, kbprogramming, kbhowto

↑ Back to the top

Article Info
Article ID : 283234
Revision : 5
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 497