XStore

Send any BizTalk alerts to specific email using a built-in Windows Task Scheduler

Introduction

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.

Solution

You might be attempted to use monitoring tools like SCOM Jump or BizTalk360 Jump ,… 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 schedtasksFigure 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 2Figure 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 3Figure 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 4Figure 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.txtdel C:\SendEmail\temp\logs.txtwevtutil 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 5Figure 5. Create Command Action
  8. Sort action and make sure that running the command action in the first action as shown in Figure 6Figure 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$emailSmtpServer="smtp.gmail.com"$emailSmtpServerPort="587"

    $emailSmtpUser="yourusername@gmail.com"

    $emailSmtpPass="yourpassword"

    $emailFrom="fromusername@gmail.com"

    $emailTo="sendtousername@gmail.com"

    $emailMessage=New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )

    $emailMessage.Subject="BizTalk Error"

    $emailMessage.IsBodyHtml=$true

    $emailMessage.Body=@"

    <p>There is a BizTalk issue</p>

    <p>Check the attachment</p>

    "@

    $emailAttachment=New-Object System.Net.Mail.Attachment("C:\SendEmail\temp\logs.txt")

    $emailMessage.Attachments.Add($emailAttachment)

    $SMTPClient=New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort )

    $SMTPClient.EnableSsl=$true

    $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.cmdpowershell C:\SendEmail\SendEmailScript.ps1Now 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
Author Details
Independent Author
Author Details

Amarnath Gupta is a visionary digital transformation leader with over two decades of experience guiding Fortune 500 organizations through enterprise-wide innovation. He has built and scaled Microsoft Dynamics 365 practices into $7.5 million revenue engines, rescued high-risk global implementations, and delivered 35 percent operational efficiency gains, 40 percent faster go-lives, and 30 percent cost optimizations across industries from manufacturing to healthcare and construction.

His passion for marrying deep technical command in Dynamics 365, Azure AI/ML, and Power Platform with strategic P&L governance has spawned proprietary IP solutions like JewelPro™ and OmniClaim Sentinel™. A catalyst for modern AMS frameworks, he leverages predictive KQL analytics and intelligent support automation to slash incident resolution times by 30 percent and cut costs by up to 30 percent.

Amarnath writes about practical strategies for data-driven decision making, end-to-end ERP/CRM implementation best practices, and the future of cloud-native architectures. His work empowers readers to transform underperforming units into high-growth engines while embedding Agile/DevOps and Zero Trust security into every layer.

  • Microsoft Dynamics 365 F&O, CE, Commerce, Field Services
  • Azure AI/ML integration and predictive analytics
  • Enterprise Application Maintenance & Support (AMS)
  • Agile/DevOps delivery and operational excellence
  • Data modernization and cloud transformation

×
Independent Author

Amarnath Gupta is a visionary digital transformation leader with over two decades of experience guiding Fortune 500 organizations through enterprise-wide innovation. He has built and scaled Microsoft Dynamics 365 practices into $7.5 million revenue engines, rescued high-risk global implementations, and delivered 35 percent operational efficiency gains, 40 percent faster go-lives, and 30 percent cost optimizations across industries from manufacturing to healthcare and construction.

His passion for marrying deep technical command in Dynamics 365, Azure AI/ML, and Power Platform with strategic P&L governance has spawned proprietary IP solutions like JewelPro™ and OmniClaim Sentinel™. A catalyst for modern AMS frameworks, he leverages predictive KQL analytics and intelligent support automation to slash incident resolution times by 30 percent and cut costs by up to 30 percent.

Amarnath writes about practical strategies for data-driven decision making, end-to-end ERP/CRM implementation best practices, and the future of cloud-native architectures. His work empowers readers to transform underperforming units into high-growth engines while embedding Agile/DevOps and Zero Trust security into every layer.

  • Microsoft Dynamics 365 F&O, CE, Commerce, Field Services
  • Azure AI/ML integration and predictive analytics
  • Enterprise Application Maintenance & Support (AMS)
  • Agile/DevOps delivery and operational excellence
  • Data modernization and cloud transformation

Related Articles