-
Notifications
You must be signed in to change notification settings - Fork 32
Migrate from Version 4 to 5
Norbert Bietsch edited this page Sep 23, 2016
·
4 revisions
The major changes are the following:
- Instead of using
System.Net.Mail
in version 4, version 5 usesMailKit
andMimeKit
. - Instead of
TextVariableManager
theSmartFormat.Net
library is used - Instead of
HtmlAgilityPack
nowAnglesharp
is used
In order to migrate to version 5.0.0 the easiest way is:
- Remove any references to
MailMergeLib
version 4 andSystem.Net.Mail
- Add a reference to
MailMergeLib
version 5,MailKit
andMimeKit
- You will get a bunch of compiler errors. Resolve them using the following table to find the counterparts for class properties and methods in version 5.
Together with the examples in the Wiki or the UnitTests you will be able to fix any remaining code issues. This migration guide refers to versions 4.0.3 and 5.0.0.
MailMergeSender v4 | MailMergeSender v5.0.0 |
---|---|
using MailMergeLib; using System.Net.Mail; |
using MailMergeLib; using MailKit; using MimeKit; |
SendAllAsync(MailMergeMessage mailMergeMessage) | Task SendAsync<T>(MailMergeMessage mailMergeMessage, IEnumerable<T> dataSource) |
SendAsync(MailMergeMessage mailMergeMessage) | Task SendAsync(MailMergeMessage mailMergeMessage, object dataItem) |
SendAll(MailMergeMessage mailMergeMessage) | Send<T>(MailMergeMessage mailMergeMessage, IEnumerable<T> dataSource) |
Send(MailMergeMessage mailMergeMessage) | Send(MailMergeMessage mailMergeMessage, object dataItem) |
SendCancel() | SendCancel(int waitTime = 0); |
OnBeforeSend | OnBeforeSend |
OnAfterSend | OnAfterSend |
OnSendFailure | OnSendFailure |
OnMergeBegin | OnMergeBegin |
OnMergeProgress | OnMergeProgress |
OnMergeComplete | OnMergeComplete |
Dispose() | Dispose() |
n/a | EventHandler<MailMessageFailureEventArgs> OnMessageFailure |
n/a | IsBusy |
ReadySent | n/a – use IsBusy |
ReadyMerged | n/a – use IsBusy |
>>>>>>>>>>>>>>> | SenderConfig / |
n/a | MaxNumOfSmtpClients |
n/a | SmtpClientConfig[] SmtpClientConfig |
>>>>>>>>>>>>>>> | SenderConfig / SmtpClientContig / |
n/a | ReadSmtpConfigurationFromWebConfig() |
SmtpHost | SmtpHost |
SmtpPort | SmtpPort |
LocalHostName | ClientDomain |
MailOutputDirectory | MailOutputDirectory |
MessageOutput | MessageOutput |
EnableSsl | SecureSocketOptions SecureSocketOptions |
UseDefaultCredentials | Credential NetworkCredential is used when set and the SMTP server requires it |
n/a | IPEndPoint LocalEndPoint |
n/a | RemoteCertificateValidationCallback ServerCertificateValidationCallback |
Timeout | Timeout |
MaxFailures | MaxFailures |
RetryDelayTime | RetryDelayTime |
DelayBetweenMessages | DelayBetweenMessages |
SetSmtpAuthentification() | Credential NetworkCredential |
n/a – SMTP Logging | IProtocolLogger GetProtocolLogger() |
n/a – SMTP Logging | LogOutputDirectory |
n/a – SMTP Logging | EnableLogOutput |
MailMergeMessage v4 | MailMergeMessage v5.0.0 |
---|---|
using MailMergeLib; using System.Net.Mail; |
using MailMergeLib; using MailKit; using MimeKit; |
Subject | Subject |
PlainText | PlainText |
HtmlText | HtmlText |
DataSource | n/a – no more BindingSource from System.Windows.Forms |
DataMember | n/a – no more BindingSource from System.Windows.Forms |
CurrentDataItem | n/a – no more BindingSource from System.Windows.Forms |
DataItemCount | n/a – no more BindingSource from System.Windows.Forms |
CurrentDataPosition | n/a – no more BindingSource from System.Windows.Forms |
OnDataChanged | n/a – no more BindingSource from System.Windows.Forms |
GetBindingSource() | n/a – no more BindingSource from System.Windows.Forms |
FileAttachments | FileAttachments |
StreamAttachments | StreamAttachments |
InlineAttachments | InlineAttachments |
StringAttachments | StringAttachments |
MailMergeAddresses | MailMergeAddresses |
Headers | HeaderList Headers |
DeliveryNotificationOptions | n/a |
Dispose() | Dispose() |
// using HtmlAgilityPack; ConvertHtmlToPlainText(IHtmlConverter converter) |
// using AngleSharp; ConvertHtmlToPlainText(IHtmlConverter converter) |
GetTextVariableManager() | MailSmartFormatter SmartFormatter |
SetVariables(Dictionary<string, string> vars) | n/a |
MailMessageGetMailMessage() | MimeMessage GetMimeMessage(object dataItem = default(object)) |
AddExternalInlineAttachment(FileAttachment att) | AddExternalInlineAttachment(FileAttachment att) |
ClearExternalInlineAttachment() | ClearExternalInlineAttachment() |
>>>>>>>>>>>>>>> | MessageConfig / |
TextTransferEncoding | ContentEncoding TextTransferEncoding |
BinaryTransferEncoding | ContentEncoding BinaryTransferEncoding |
CharacterEncoding | CharacterEncoding |
CultureInfo | CultureInfo |
FileBaseDir | FileBaseDirectory |
IgnoreEmptyRecipientAddr | IgnoreIllegalRecipientAddresses |
Priority | MessagePriority Priority |
n/a | MailboxAddress StandardFromAddress |
n/a | Organization |
Xmailer | Xmailer |
n/a | MessageConfig / SmartFormatterConfig |
n/a | ParseErrorAction |
n/a | FormatErrorAction |
MailMergeAddress v4 | MailMergeAddress v5.0.0 |
---|---|
using MailMergeLib; using System.Net.Mail; |
using MailMergeLib; using MailKit; using MimeKit; |
var mmm = new MailMergeMessage(); mmm.MailMergeAddresses.Add(newMailMergeAddress(MailAddressType.To, " [email protected]", " name ")); | var mmm = new MailMergeMessage(); // sequence of name and email changed, following // common convention mmm.MailMergeAddresses.Add(newMailMergeAddress(MailAddressType.To, "name", "[email protected]")); |