Showing posts with label Adapters. Show all posts
Showing posts with label Adapters. Show all posts

Thursday, September 13, 2007

Something brewing... Not ready for Prime Time.

It's been quiet on the blogging front for awhile.  Things have been pretty quiet at work and nothing of great value has been discovered.  I have been playing with WPF and WCF a bit.  I hooked up BTS 2006 to a WCF Send Port which was pretty cool.  I didn't think the transport properties form was very "friendly".  There were several values that were provided as drop-downs, but the drop-down boxes were empty.  I had to go to the BTSNTSVC.exe.config file to determine the proper values.  Once I got beyond that, I was rockin' and rollin'.  I'm thinking of setting up a VM with R2 on it and playing with it a little more.  I'll post my findings as they come.  Other than that, I have really enjoyed playing with WPF and LINQ.  Some very cool stuff, not what I am doing, but the technology. :)

Tuesday, August 7, 2007

BizTalk SMTP Adapter is Missing BCC Functionality

Ok, so this probably comes to no surprise to many of you.  I remember running in to this problem when I was using BTS 2004.  However, I thought that the community's cries would be answered with BTS 2006.  I have not had a need for it until now, so I never checked, but again the ability to BCC using the SMTP Adapter does not exist.  Fortunately, there are many ways to skin this cat.  The first 2 that come to mind are:

  1. Create 2 separate email messages within BizTalk: 1 for your original recipients, and 1 for your BCC recipients
    1. Don't forget to tell them they received this as a BCC and list the original recipients.
    2. Yeah... won't end up biting you in the butt later on.
  2. Create a referenced assembly to manage your SMTP needs.
    1. Again, there are tons of SMTP DLLs floating around in the ether, but you can easily create your own with very little code.  Depending how basic your needs are, you can accomplish it with very few lines of code. 

      using System.Net.Mail;

      SmtpClient client = new SmtpClient("server");
      using (MailMessage message = new MailMessage("from", "to", "subject", "Body"))
      {
          client.Send(message);
      }

      But if your needs were that simple, you could just use the SMTP Adapter.

Anyway, I whipped up some code that would handle my needs.  I did not need to support attachments, although it shouldn't be too difficult to modify my code to include them.

Essentially, I created 2 classes:  SMTPHelper and SMTPMessage.

SMTPMessage contains the necessary property values used to send an email.
SMTPHelper contains a single method (SendMail) that accepts a SMTPMessage parameter.  SendMail uses the values within the SMTPMessage object to create SmtpClient and MailMessage objects and perform the necessary actions to deliver the email.  Basic error handling is included, but can surely be expanded upon.

Within BizTalk, I created a variable called smtpMessage of type BAJ.Utilities.SMTPMessage.  Inside my orchestration, I placed the following code within an expression shape.

smtpMessage = new BAJ.Utilities.SMTPMessage();

smtpMessage.SMTPServer = smtpServer;
smtpMessage.FromAddress = smtpFromAddress;
smtpMessage.FromName = smtpFromName;
smtpMessage.ToList = strToList;
smtpMessage.CCList = "";
smtpMessage.BCCList = strBCCList;
smtpMessage.Subject = "[enter subject here]";
smtpMessage.Body = "[enter message here]";
smtpMessage.IsHTML = true;
smtpMessage.Priority = System.Net.Mail.MailPriority.Normal;

BAJ.Utilities.SMTPHelper.SendMail(smtpMessage);

In my process, smtpServer, smtpFromAddress, and smtpFromName are all string variables whose values are stored as AppSettings.

Here is the code for my SMTPHelper class:  SMTPHelper.zip

BizTalk LOB Whitepapers

Earlier in the year, I published a couple of Whitepapers for Microsoft on the topic of using the BizTalk PeopleSoft and Siebel LOB Adapters. Since then, I have run across a few other helpful pieces of information that I thought I might share in future posts. For now, here are the links to the papers.

  1. Link to BizTalk Server 2006 Adapter website: http://msdn2.microsoft.com/en-us/biztalk/aa937652.aspx
  2. Link to PeopleSoft LOB Adapter Whitepaper: http://download.microsoft.com/download/1/6/9/16968441-c6c8-4bd0-9410-5f4014bc61f0/peoplesoft.doc
  3. Link to Siebel LOB Adapter Whitepaper: http://download.microsoft.com/download/1/6/9/16968441-c6c8-4bd0-9410-5f4014bc61f0/siebel.doc