public MapiSendMailReturnCode SendEmail(EmailMessage message) { // Translate files & recipients to unmanaged MAPI structures using (var files = Unmanaged.CopyOf(GetFiles(message))) using (var recips = Unmanaged.CopyOf(GetRecips(message))) { // Create a MAPI structure for the entirety of the message var mapiMessage = new MapiMessage { subject = message.Subject, noteText = message.BodyText, recips = recips, recipCount = recips.Length, files = files, fileCount = files.Length }; // Determine the flags used to send the message var flags = MapiSendMailFlags.None; if (!message.AutoSend) { flags |= MapiSendMailFlags.Dialog; } if (!message.AutoSend || !message.SilentSend) { flags |= MapiSendMailFlags.LogonUI; } // Send the message var clientName = userConfigManager.Config.EmailSetup?.SystemProviderName; var mapiSendMail = systemEmailClients.GetDelegate(clientName); return(mapiSendMail(IntPtr.Zero, IntPtr.Zero, mapiMessage, flags, 0)); } }
public MapiSendMailReturnCode SendEmail(string clientName, EmailMessage message) { var(mapiSendMail, mapiSendMailW) = systemEmailClients.GetDelegate(clientName, out bool unicode); // Determine the flags used to send the message var flags = MapiSendMailFlags.None; if (!message.AutoSend) { flags |= MapiSendMailFlags.Dialog; } if (!message.AutoSend || !message.SilentSend) { flags |= MapiSendMailFlags.LogonUI; } return(unicode ? SendMailW(mapiSendMailW, message, flags) : SendMail(mapiSendMail, message, flags)); }
public MapiSendMailReturnCode SendEmail(EmailMessage message) { var clientName = userConfigManager.Config.EmailSetup?.SystemProviderName; var(mapiSendMail, mapiSendMailW) = systemEmailClients.GetDelegate(clientName, out bool unicode); // Determine the flags used to send the message var flags = MapiSendMailFlags.None; if (!message.AutoSend) { flags |= MapiSendMailFlags.Dialog; } if (!message.AutoSend || !message.SilentSend) { flags |= MapiSendMailFlags.LogonUI; } return(unicode ? SendMailW(mapiSendMailW, message, flags) : SendMail(mapiSendMail, message, flags)); }