As a BizTalk administrator, you need to know about any issues in your BizTalk environment. It is crucial to know about these issues before they become real problems or cause any unnecessary outage for any integration services provided by your BizTalk server.

In this article I will demonstrate an easy way to send alerts in case there are any errors or warnings in the BizTalk environment.

Problem Statement

You may have some customers connecting to your integration middleware through receive adapters, such as POP3, SFTP, FTP, File, etc. In some cases you may get some warnings and errors which affect these receive adapters and make them disabled once the error threshold is exceeded.

In many instances, you would not be able to use the BizTalk Administration Console for alerting as these entries do not even register in the BizTalk Message Box.  

Therefore, it is very important to be notified before the end users prompted with warning or error messages when they are trying to upload into integration middleware. It is equally important to take a proactive approach to resolve any upcoming issues you might be experiencing with your BizTalk server.


You might be attempted to use monitoring tools like SCOM or BizTalk360,... These tools are not free and some companies might find them costly to license and implement.

If your project does not have a budget to deploy these motioning tools, there is an easy way to get BizTalk alerts by using a combination of PowerShell scripting and the built-in Windows Task Scheduler through the following steps:
  1. Select Windows Start Button ->Control Panel->Administrative Tools -> Task Scheduler as shown in Figure 1 or use the shortcut command in run window control schedtasks

    Figure 1. Accessing Task Scheduler

  2. In Task Scheduler window, select Microsoft folder->click on create task -> in General Tab Name the task as shown in Figure 2

    Figure 2. Create Task

  3. Select Trigger Tab->Click New button-> in the Begin the task select on an event ->select custom->click New Event  Filter button-> in Event Sources select BizTalk -> In case you want to filter by using event id you can set an event id as shown in Figure 3 

    Figure 3. Create Trigger

  4. Select Action Tab->Click New Button->In Action select Send an e-mail->set email settings properties as shown in Figure 4

    Figure 4.  Create Exchange Email Action

  5. If you want to add attachment of event logs to be included in email, then you need to create a new action to run the following command  which write your filter log into a text file in my case I filtered on EventId 5740 which is pop3 warning that happens once pop3 user not authenticated and save it in this path C:\SendEmail\temp\logs.txt

    del C:\SendEmail\temp\logs.txt
    wevtutil qe Application
    "/q:*[System [(EventID=5740)]]"
    /f:text /rd:true /c:1> C:\SendEmail\temp\logs.txt
  6. Save command into cmd file and rename it into path C:\SendEmail\WriteLog.cmd
  7. Create new action -> In Action field, select start a program-> Set Program/Script Path as shown in Figure 5

    Figure 5. Create Command Action

  8. Sort action and make sure that running the command action in the first action as shown in Figure 6

      Figure 6. Sort actions

  9. In case you do not want to use exchange mail server, then you can write the following powershell script and save it in this path C:\SendEmail\SendEmailScript.ps1 

    $emailMessage=New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )
    $emailMessage.Subject="BizTalk Error"
    <p>There is a BizTalk issue</p>
    <p>Check the attachment</p>
    $emailAttachment=New-Object System.Net.Mail.Attachment("C:\SendEmail\temp\logs.txt")
    $SMTPClient=New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort )
    $SMTPClient.Credentials=New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );
    $SMTPClient.Send( $emailMessage )

  10. Create another command file to run powershell script as below and save it in this path C:\SendEmail\RunPowerShellScript.cmd

    powershell C:\SendEmail\SendEmailScript.ps1

    Now SendEmail folder should be as shown in Figure 7

    Figure 7. Files inside SendEmail Folders

  11. Update Send Email Action which we created in step 4 to run a program with path C:\SendEmail\RunPowerShellScript.cmd as shown in 

    Figure 8. Edit Action to use PowerShell script

  12. To test your work, create pop3 receive location and set a wrong username and password


In this article, I walked-through in step by step how to use an easy way to send any BizTalk alerts to specific email using a built-in Windows Task Scheduler.

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.