How to send an email from a BizTalk Expression shape (without using the SMTP Send Ports).
Note: There are two mail objects, the older one is System.Web.Mail and the newer one It also shows how to connect to an SMTP Host (Server) that requires userid/password authentication.
Note: The SMTPHost, from email, user/password were retrieved in the previous expression shape from the <AppSettings> of the BTNTSVC.exe.config file.
{!{code}!}czo3NzQ6XCIKb2JqTWFpbCA9IG5ldyBTeXN0ZW0uTmV0Lk1haWwuTWFpbE1lc3NhZ2UoKTsKCm9iak1haWxBZGRyZXNzRnJvbSA9IG57WyYqJl19ZXcgU3lzdGVtLk5ldC5NYWlsLk1haWxBZGRyZXNzKHN0ck1haWxGcm9tKTsKb2JqTWFpbC5Gcm9tID0gb2JqTWFpbEFkZHJlc3NGcntbJiomXX1vbTsKCm9iak1haWxBZGRyZXNzVG8gPSBuZXcgU3lzdGVtLk5ldC5NYWlsLk1haWxBZGRyZXNzKG1zZ0VtYWlsRnJvbVNRTC5FbWFpe1smKiZdfWxBZGRyZXNzKTsKb2JqTWFpbC5Uby5BZGQob2JqTWFpbEFkZHJlc3NUbyk7CgpvYmpNYWlsLlN1YmplY3QgPSBtc2dFbWFpbEZyb217WyYqJl19U1FMLlN0YXR1c19Db2RlLkRlc2NyaXB0aW9uOwoKb2JqTWFpbC5Cb2R5ID0KICAgIG1zZ0VtYWlsRnJvbVNRTC5TdGF0dXNfQ29kZXtbJiomXX0uVGV4dCArCiAgICBcIiZsdDtCUiZndDsmbHQ7QlImZ3Q7XCIgKwogICAgXCImbHQ7YSBocmVmPVwnXCIgKyBtc2dFbWFpbEZyb21TUUwuV2V7WyYqJl19YlBhZ2VBZGRyZXNzICsgXCJcJyZndDtcIiArCiAgICBtc2dFbWFpbEZyb21TUUwuV2ViUGFnZUFkZHJlc3MgKyBcIiZsdDsvYSZndDtcIjsKe1smKiZdfQpvYmpNYWlsLklzQm9keUh0bWwgPSB0cnVlOwoKb2JqQ3JlZGVudGlhbHMgPSBuZXcgU3lzdGVtLk5ldC5OZXR3b3JrQ3JlZGVudGl7WyYqJ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