Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

  Home  |   Contact  |   Syndication    |   Login
  187 Posts | 2 Stories | 198 Comments | 4 Trackbacks

News



Twitter | LinkedIn | Xing

Archives

Post Categories

BizTalk

C#

Enterprise Library

SAP

SQL Server

Technologie

For sending emails out of a BizTalk-Orchestration to varying recipients you can use a dynamic send port. The sending-parameters you can set directly in the orchestration.

You need a "Message Assignment" and an "Expression"-shape.

In the "Message Assignment"-shape you set the parameters for the smtp-stuff:

msgSend(SMTP.CC) = "xyz@sample.com; ...";
msgSend(SMTP.Subject) = "TESTMAIL: blabla";
msgSend(SMTP.From) = "BizTalk@sample.com";
msgSend(SMTP.SMTPHost) = "smtp.sample.com";
msgSend(SMTP.SMTPAuthenticate) = 0;

The recipient is configurable as the URI-address of the adapter as an property of the dynamic sending port itself in the "Expression"-shape:

portSend(Microsoft.XLANGs.BaseTypes.Address)=
  "mailto:abc@sample.com"

If you want set the recipient as the content of a message, a simple way is to use XPath like in this example:

portSend(Microsoft.XLANGs.BaseTypes.Address) =
  "mailto:" + 
  (System.String) xpath(msgSend, "string(/*[local-name()='Root' and namespace-uri()='http://SampleNamespace']/*[local-name()='To' and namespace-uri()=''])");
for a XML-document like

<Root>
  blabla
  <To>abc@sample.com</To>
</Root>
posted on Friday, November 24, 2006 9:08 PM

Feedback

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 1/14/2008 10:58 AM Beatriz
Hi,

This is a very useful post, but do you know how I can do the same in the class library proyect and call it from the "Message Asignment" shape?
I would like to put it out of the orquestration.
Thanks in advance!!

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 1/14/2008 11:39 AM Marko Apfel
Hi Beatriz!
For such cases i use the following approach:

program a class with (static) methods wich delivers you the strings you need (and put it in the GAC).
for instance "SmtpKonfigurator":

public class SmtpKonfigurator
{
private SmtpKonfigurator()
{Initialize();}

private void Initialize()
{_configuration = ConfigurationHelper.OpenConfiguration();}

public static string GetSmtpTo()
{
if (_smtpTo == null)
_smtpTo = ConfigurationHelper.ReadAppSettingKey(Singleton._configuration, "SMTP.To", true);
return _smtpTo;
}

public static string GetSmtpCc()
public static string GetSmtpFrom()
public static string GetSmtpServer()

during the initialization-code i read my relevant informations from an xml-config-file. you can do that dynamically for each access.

in your orchestration you configure your message with a statement like this:
msgException(SMTP.CC) = EsriDe.Eai.BizTalk.Tool.SmtpKonfigurator.GetSmtpCc();

So your dynamic stuff is in an class library outside your orchestration, and the orchestration is "code-stable"

Hope that will help you ...



# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 4/14/2008 3:42 AM Yolanda
Hi,

I am working on a simple Send-email project with SMTP. In the orchestration, I have one receive, one message assignment, and one send (of course with receive/send ports too). But when I copy an XML file to the receive folder, I received error message in Event viewer:

The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.

Why? Could someone answer me? Thanks in advance.

p.s. I'm new in Biztalk!


# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 4/14/2008 3:58 AM Marko Apfel
Normally this Messages indicates, that your XML cant be matched with a xml-schema. You are really shure, that your XML is a valid instance for the "incoming-schema"?

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 6/20/2008 10:52 AM Anwar
Did u use XMlDisassembler in receive pipeline?coz it is resposible for promoting the MessageType property based on which ur orchestration will subscribe....(if no other properties are specified in the receive shape filter expression).

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 12/2/2008 2:36 AM Per Lundberg
Hi Marko,

Good post!

Just one hint: I don't think you should recommend people using xpath() to get data from a message. Sure, you *can* do it but it is not so robust. If the schema of the message is changed, you wouldn't get a compile-time error but rather a runtime error.

I would suggest to use distinguished fields for fetching the email address in you last example, rather than xpath. That way, if the schema is changed so that the email address is located in a different place, you will notice that when you try to compile the project -- which is (IMO) superior than seeing it at runtime.

Best regards,
Per

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 12/22/2008 5:07 AM Kuldip
Can anybody suggest me How to create Dynamic send port for MS CRM.
I want to configure a dynamic send port using CRM adapter
i want to know how to set Address URL, password and username etc. for this.
Thanks in advance

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 3/25/2009 6:30 AM Yolanda
Hi,

In the Message Assignment, I have already setup the SMTP properties. However, when I received the mail, the subject and the content are not the ones that I set. Instead the subject of the mail looks like an MessageID.

I used dynamic send port and in the SMTP adapter in BizTalk Admin Console, I have setup the email account accordingly.

Could someone give me a hint? Thanks!

# re: Configuration of the BizTalk SMTP-Adapter via a dynamic port 6/20/2012 3:32 PM Edward Wisniowski
When I attempt to place your E-mail code in the Expression object I get the following error from Visual Studio:

"msgSend does not exist in process are you missing an assembly or reference?"

is msgSend the port or some other object?

I am stuck.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: