I didn't like the core's implementation of email functions (i wanted to be able to send automatic cc's to an admin for all outgoing mails)... so i extended it with my own; here it is:
Imports
DotNetNuke.Services.Mail
Imports
DotNetNuke.Common.Globals
Namespace
EmailPublic Class HelperPublic Shared Sub SendUserRDMail(ByVal ToAddress As String, ByVal MailPriority As MailPriority, ByVal Subject As String, ByVal Body As String, ByVal BodyFormat As MailFormat, ByVal PortalId As String)Dim FromAddress As String = RealDropzone.RDSettings.GetSetting(RealDropzone.RDSettings.Settings.Email_FromAddress, PortalId)Dim SentMailLogAddress As String = RealDropzone.RDSettings.GetSetting(RealDropzone.RDSettings.Settings.Email_SentMailLogAddress, PortalId)Dim HTMLBREAK As String = ""
If BodyFormat = MailFormat.Html Then HTMLBREAK = "<br/>"
Dim SMTPServer As String = ""
Dim SMTPAuthentication As String = ""
Dim SMTPUsername As String = ""
Dim SMTPPassword As String = ""
Subject = DropzoneName &
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.Append(Body)
SendMail(FromAddress, ToAddress,
SendMail(FromAddress, SentMailLogAddress,
Dim DropzoneName As String = RealDropzone.RDSettings.GetSetting(RealDropzone.RDSettings.Settings.GeneralInfo_DropzoneName, PortalId)" - " & SubjectIf CStr(HostSettings("SMTPServer")) <> "" Then SMTPServer = CStr(HostSettings("SMTPServer"))If CStr(HostSettings("SMTPAuthentication")) <> "" Then SMTPAuthentication = CStr(DotNetNuke.Common.Globals.HostSettings("SMTPAuthentication"))If CStr(HostSettings("SMTPUsername")) <> "" Then SMTPUsername = CStr(HostSettings("SMTPUsername"))If CStr(HostSettings("SMTPPassword")) <> "" Then SMTPPassword = CStr(HostSettings("SMTPPassword"))Dim strLogBody As New System.Text.StringBuilder"RealDropzone Automated Email" & HTMLBREAK)"FromAddress: " & FromAddress & HTMLBREAK)"To Address....:" & ToAddress & HTMLBREAK)"BodyFormat....:" & BodyFormat.ToString & HTMLBREAK)"---------------------------------------------------" & HTMLBREAK)"Subject: " & Subject & HTMLBREAK)"Body:" & HTMLBREAK & HTMLBREAK)Dim strLogSubject As String = "Message Sent: " & Subject"", "", DotNetNuke.Services.Mail.MailPriority.Normal, Subject, Body, BodyFormat, System.Text.Encoding.UTF8, "")"", "", DotNetNuke.Services.Mail.MailPriority.Normal, strLogSubject, strLogBody.ToString, BodyFormat, System.Text.Encoding.UTF8, "")End Sub
SendMail(FromAddress, SentMailLogAddress,
Public Shared Sub SendLogRDMail(ByVal MailPriority As MailPriority, ByVal Subject As String, ByVal Body As String, ByVal BodyFormat As MailFormat, ByVal PortalId As String)Dim FromAddress As String = RealDropzone.RDSettings.GetSetting(RealDropzone.RDSettings.Settings.Email_FromAddress, PortalId)Dim SentMailLogAddress As String = RealDropzone.RDSettings.GetSetting(RealDropzone.RDSettings.Settings.Email_SentMailLogAddress, PortalId)"", "", MailPriority, Subject, Body, BodyFormat, System.Text.Encoding.UTF8, "")End Sub
Public Shared Sub SendMail(ByVal FromAddress As String, _ByVal ToAddress As String, _ByVal AdminAddress As String, _ByVal Priority As MailPriority, _ByVal subject As String, _ByVal body As String, _ByVal BodyFormat As MailFormat)Dim HTMLBREAK As String = ""
If BodyFormat = MailFormat.Html Then HTMLBREAK = "<br/>"
Dim SMTPServer As String = ""
Dim SMTPAuthentication As String = ""
Dim SMTPUsername As String = ""
Dim SMTPPassword As String = ""
' SMTP server configuration
DotNetNuke.Services.Mail.Mail.SendMail(FromAddress, ToAddress,
If CStr(HostSettings("SMTPServer")) <> "" Then SMTPServer = CStr(HostSettings("SMTPServer"))If CStr(HostSettings("SMTPAuthentication")) <> "" Then SMTPAuthentication = CStr(DotNetNuke.Common.Globals.HostSettings("SMTPAuthentication"))If CStr(HostSettings("SMTPUsername")) <> "" Then SMTPUsername = CStr(HostSettings("SMTPUsername"))If CStr(HostSettings("SMTPPassword")) <> "" Then SMTPPassword = CStr(HostSettings("SMTPPassword"))"", "", Priority, subject, BodyFormat, System.Text.Encoding.UTF8, body, "", SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword)If Not String.IsNullOrEmpty(AdminAddress) Then
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.AppendLine(HTMLBREAK)
strLogBody.AppendLine(
strLogBody.Append(body)
DotNetNuke.Services.Mail.Mail.SendMail(FromAddress, AdminAddress,
Dim strLogBody As New System.Text.StringBuilder"RealDropzone Automated Email" & HTMLBREAK)"FromAddress: " & FromAddress & HTMLBREAK)"To Address....:" & ToAddress & HTMLBREAK)"BodyFormat....:" & BodyFormat.ToString & HTMLBREAK)"---------------------------------------------------" & HTMLBREAK)"Subject: " & subject & HTMLBREAK)"Body:" & HTMLBREAK & HTMLBREAK)Dim strLogSubject As String = "Message Sent: " & subject"", "", Priority, subject, BodyFormat, System.Text.Encoding.UTF8, body, "", SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword)End If
End Sub
Private Shared Sub SendMail(ByVal FromAddress As String, _ByVal ToAddress As String, _ByVal CCAddress As String, _ByVal BCCAddress As String, _ByVal Priority As MailPriority, _ByVal Subject As String, _ByVal Body As String, _ByVal BodyFormat As MailFormat, _ByVal BodyEncoding As System.Text.Encoding, _ByVal Attachment As String)Dim SMTPServer As String = ""
Dim SMTPAuthentication As String = ""
Dim SMTPUsername As String = ""
Dim SMTPPassword As String = ""
' SMTP server configuration
DotNetNuke.Services.Mail.Mail.SendMail(FromAddress, ToAddress, CCAddress, BCCAddress, Priority, Subject, BodyFormat, BodyEncoding, Body, Attachment, SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword)
If CStr(HostSettings("SMTPServer")) <> "" Then SMTPServer = CStr(HostSettings("SMTPServer"))If CStr(HostSettings("SMTPAuthentication")) <> "" Then SMTPAuthentication = CStr(DotNetNuke.Common.Globals.HostSettings("SMTPAuthentication"))If CStr(HostSettings("SMTPUsername")) <> "" Then SMTPUsername = CStr(HostSettings("SMTPUsername"))If CStr(HostSettings("SMTPPassword")) <> "" Then SMTPPassword = CStr(HostSettings("SMTPPassword"))End Sub
End
End Class Namespace