'
' DotNetNuke - http:'www.dotnetnuke.com
' Copyright (c) 2002-2007
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports System
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Security.Roles
Imports System.Collections.Generic
Imports System.Web.Mail
Imports System.Web.UI.WebControls
Imports System.Collections
Namespace DotNetNuke.Modules
Public Class AjaxEmail
Inherits Entities.Modules.PortalModuleBase
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If DotNetNuke.Framework.AJAX.IsInstalled Then
DotNetNuke.Framework.AJAX.RegisterScriptManager()
DotNetNuke.Framework.AJAX.WrapUpdatePanelControl(pnlEmail, True)
DotNetNuke.Framework.AJAX.RegisterPostBackControl(btnPostBack)
End If
If (UserId <> -1) Then
txtFrom.Text = UserInfo.Email
Else
lblEmailSent.Visible = True
lblEmailSent.Text = "You must be logged in to email"
btnSendEmail.Visible = False
End If
End Sub
Protected Sub btnSendEmail_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPostBack.Click
If ((txtSubject.Text.Trim <> "") And (txtMessage.Text.Trim <> "")) Then
Dim intGridViewRow As Integer
Dim GridViewRowCollection As GridViewRowCollection = CType(AJAXUsers1.GridViewRows, GridViewRowCollection)
intGridViewRow = 0
Do While (intGridViewRow <= (GridViewRowCollection.Count - 1))
Dim GridViewRow As GridViewRow = CType(GridViewRowCollection(intGridViewRow), GridViewRow)
Dim LabelEmail As Label = CType(GridViewRow.FindControl("lblEmail2"), Label)
DotNetNuke.Services.Mail.Mail.SendMail(txtFrom.Text, LabelEmail.Text, "", txtSubject.Text, txtMessage.Text, "", "HTML", "", "", "", "")
intGridViewRow = (intGridViewRow + 1)
Loop
lblEmailSent.Text = "Email Sent"
Else
lblEmailSent.Text = "You must have recipients, subject, and message"
End If
End Sub
Protected Sub btnSendEmail_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendEmail.Click
'Sleep so that you can see the progress indicator - remove when in production
System.Threading.Thread.Sleep(1000)
If ((txtSubject.Text.Trim <> "") And (txtMessage.Text.Trim <> "")) Then
Dim intGridViewRow As Integer
Dim GridViewRowCollection As GridViewRowCollection = CType(AJAXUsers1.GridViewRows, GridViewRowCollection)
intGridViewRow = 0
Do While (intGridViewRow <= (GridViewRowCollection.Count - 1))
Dim GridViewRow As GridViewRow = CType(GridViewRowCollection(intGridViewRow), GridViewRow)
Dim LabelEmail As Label = CType(GridViewRow.FindControl("lblEmail2"), Label)
DotNetNuke.Services.Mail.Mail.SendMail(txtFrom.Text, LabelEmail.Text, "", txtSubject.Text, txtMessage.Text, "", "HTML", "", "", "", "")
intGridViewRow = (intGridViewRow + 1)
Loop
lblEmailSent.Text = "Email Sent"
Else
lblEmailSent.Text = "You must have recipients, subject, and message"
End If
End Sub
End Class
End Namespace