Skip to content

Instantly share code, notes, and snippets.

@tpokorra
Created October 8, 2019 05:19
Show Gist options
  • Save tpokorra/1f81271aec0ef58b9c8b564c7436744d to your computer and use it in GitHub Desktop.
Save tpokorra/1f81271aec0ef58b9c8b564c7436744d to your computer and use it in GitHub Desktop.
Test sending Mail with Ict.Common.IO and MimeKit
// mcs testSendMail.cs -r:System.Data -r:delivery/bin/Ict.Common.IO.dll -r:delivery/bin/Ict.Common.dll -r:delivery/bin/MimeKit.dll
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Collections;
using System.Collections.Specialized;
using System.Dynamic;
using System.Globalization;
using System.Xml;
using System.Text;
using System.IO;
using System.Data;
using MimeKit;
using Ict.Common;
using Ict.Common.IO;
public class MainClass
{
static public void Main()
{
new TLogging("../../log/test.log");
new TAppSettingsManager("/home/op_dev/etc/PetraServerConsole.config");
TLogging.DebugLevel = TAppSettingsManager.GetInt16("Client.DebugLevel", 0);
if (TAppSettingsManager.GetValue("SmtpHost", TSmtpSender.SMTP_HOST_DEFAULT).
EndsWith(TSmtpSender.SMTP_HOST_DEFAULT))
{
TLogging.Log("for TestSendMail: need to configure SmptHost in the config file");
return;
}
TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
TSmtpSender sender = new TSmtpSender();
if (!sender.SendEmail(
"[email protected]",
"OpenPetra Test",
"[email protected]",
"This is a test subject",
"Please ignore this e-mail!")) {
Console.WriteLine("problem");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment