Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedSend out verification code and email programatically  Send out verification code and email programatically
Previous
 
Next
New Post
4/8/2010 5:16 AM
 

Hi!

I'm requested to generate a process in DNN to re-send the verification email to all users they has not verificated it (Unathorized Users).

I'm thinking on creating an item in the scheduler. Everything was right, but when I try to use Services.Mail.Mail.SendMail(oUser, Services.Mail.MessageType.UserRegistrationVerified, ps) I can´t get PortalSettings. Is there another way to re-send verification e-mail to all unathorized  users ( o any of then)?

 

 

Thanks

Victor

 
New Post
4/9/2010 2:41 PM
 

Remember when working with a scheduled job, you are not guaranteed to have a valid HTTP Context which can prevent you from getting access to information such as the current portal etc.

Be sure that you are retreiving the needed information and passing it a long.


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
4/10/2010 11:49 PM
 

I am using the following in a scheduled task that does not require portalsettings:

DotNetNuke.Services.Mail.Mail.SendMail(strFromEmail, strToEmail, "", strSubject, strContent, "", "HTML", "", "", "", "")

If for whatever reason you cannot use the above, the following should work to get portalsettings:

Dim portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() 

Worst case, here is a function to build your own portalsettings:

    Public Shared Function CreateNewPortalSettings(ByVal portalId As Integer) As DotNetNuke.Entities.Portals.PortalSettings

            'new settings object

            Dim ps As New PortalSettings()

            'controller instances

            Dim pc As New PortalController()

            Dim tc As New TabController()

            Dim pac As New PortalAliasController()


            'get the first portal alias found to be used as the current portal alias

            Dim portalAlias As PortalAliasInfo = Nothing

            Dim aliases As Entities.Portals.PortalAliasCollection = pac.GetPortalAliasByPortalID(portalId)

            Dim aliasKey As String = ""

            If aliases IsNot Nothing AndAlso aliases.Count > 0 Then

                'get the first portal alias in the list and use that

                For Each key As String In aliases.Keys

                    aliasKey = key

                    portalAlias = aliases(key)

                    Exit For

                Next

            End If

            'get the portal and copy across the settings

            Dim portal As PortalInfo = pc.GetPortal(portalId)

            If portal IsNot Nothing Then

                ps.PortalAlias = portalAlias

                ps.PortalId = portal.PortalID

                ps.PortalName = portal.PortalName

                ps.LogoFile = portal.LogoFile

                ps.FooterText = portal.FooterText

                ps.ExpiryDate = portal.ExpiryDate

                ps.UserRegistration = portal.UserRegistration

                ps.BannerAdvertising = portal.BannerAdvertising

                ps.Currency = portal.Currency

                ps.AdministratorId = portal.AdministratorId

                ps.Email = portal.Email

                ps.HostFee = portal.HostFee

                ps.HostSpace = portal.HostSpace

                ps.PageQuota = portal.PageQuota

                ps.UserQuota = portal.UserQuota

                ps.AdministratorRoleId = portal.AdministratorRoleId

                ps.AdministratorRoleName = portal.AdministratorRoleName

                ps.RegisteredRoleId = portal.RegisteredRoleId

                ps.RegisteredRoleName = portal.RegisteredRoleName

                ps.Description = portal.Description

                ps.KeyWords = portal.KeyWords

                ps.BackgroundFile = portal.BackgroundFile

                ps.GUID = portal.GUID

                ps.SiteLogHistory = portal.SiteLogHistory

                ps.AdminTabId = portal.AdminTabId

                ps.SuperTabId = portal.SuperTabId

                ps.SplashTabId = portal.SplashTabId

                ps.HomeTabId = portal.HomeTabId

                ps.LoginTabId = portal.LoginTabId

                ps.UserTabId = portal.UserTabId

                ps.DefaultLanguage = portal.DefaultLanguage

                ps.TimeZoneOffset = portal.TimeZoneOffset

                ps.HomeDirectory = portal.HomeDirectory

                ps.Version = portal.Version

                'ps.AdminSkin = DotNetNuke.UI.Skins.SkinController.ge(SkinInfo.RootSkin, portalId, SkinType.Admin)

                'If ps.AdminSkin Is Nothing Then

                '    ps.AdminSkin = SkinController.GetSkin(SkinInfo.RootSkin, DotNetNuke.Common.Utilities.Null.NullInteger, SkinType.Admin)

                'End If

                'ps.PortalSkin = SkinController.GetSkin(SkinInfo.RootSkin, portalId, SkinType.Portal)

                'If ps.PortalSkin Is Nothing Then

                '    ps.PortalSkin = SkinController.GetSkin(SkinInfo.RootSkin, DotNetNuke.Common.Utilities.Null.NullInteger, SkinType.Portal)

                'End If

                'ps.AdminContainer = SkinController.GetSkin(SkinInfo.RootContainer, portalId, SkinType.Admin)

                'If ps.AdminContainer Is Nothing Then

                '    ps.AdminContainer = SkinController.GetSkin(SkinInfo.RootContainer, DotNetNuke.Common.Utilities.Null.NullInteger, SkinType.Admin)

                'End If

                'ps.PortalContainer = SkinController.GetSkin(SkinInfo.RootContainer, portalId, SkinType.Portal)

                'If ps.PortalContainer Is Nothing Then

                '    ps.PortalContainer = SkinController.GetSkin(SkinInfo.RootContainer, DotNetNuke.Common.Utilities.Null.NullInteger, SkinType.Portal)

                'End If

                ps.Pages = portal.Pages

                ps.Users = portal.Users

                ' set custom properties

                If DotNetNuke.Common.Utilities.Null.IsNull(ps.HostSpace) Then

                    ps.HostSpace = 0

                End If

                If DotNetNuke.Common.Utilities.Null.IsNull(ps.DefaultLanguage) Then

                    ps.DefaultLanguage = DotNetNuke.Services.Localization.Localization.SystemLocale

                End If

                If DotNetNuke.Common.Utilities.Null.IsNull(ps.TimeZoneOffset) Then

                    ps.TimeZoneOffset = DotNetNuke.Services.Localization.Localization.SystemTimeZoneOffset

                End If

                ps.HomeDirectory = (DotNetNuke.Common.Globals.ApplicationPath & "/") + portal.HomeDirectory & "/"

                ' get application version

                Dim arrVersion As String() = DotNetNuke.Common.Assembly.glbAppVersion.Split("."c)

                Dim intMajor As Integer = 0

                Dim intMinor As Integer = 0

                Dim intBuild As Integer = 0

                Int32.TryParse(arrVersion(0), intMajor)

                Int32.TryParse(arrVersion(1), intMinor)

                Int32.TryParse(arrVersion(2), intBuild)

                ps.Version = ((intMajor.ToString() & ".") + intMinor.ToString() & ".") + intBuild.ToString()

            End If

            'Add each portal Tab to DekstopTabs

            Dim portalTab As TabInfo = Nothing

            Dim first As Boolean = True

            For Each tabPair As KeyValuePair(Of Integer, TabInfo) In tc.GetTabsByPortal(ps.PortalId)

                ' clone the tab object ( to avoid creating an object reference to the data cache )

                portalTab = tabPair.Value.Clone()

                ' set custom properties

                If portalTab.TabOrder = 0 Then

                    portalTab.TabOrder = 999

                End If

                If DotNetNuke.Common.Utilities.Null.IsNull(portalTab.StartDate) Then

                    portalTab.StartDate = System.DateTime.MinValue

                End If

                If DotNetNuke.Common.Utilities.Null.IsNull(portalTab.EndDate) Then

                    portalTab.EndDate = System.DateTime.MaxValue

                End If

                ps.DesktopTabs.Add(portalTab)


                'assign the first 'normal' tab as the active tab - could be the home tab, if it

                'still exists, or it will be after the admin tab(s)

                If first AndAlso (portalTab.TabID = portal.HomeTabId OrElse portalTab.TabID > portal.AdminTabId) Then

                    ps.ActiveTab = portalTab

                    first = False

                End If

            Next

            'last gasp chance in case active tab was not set

            If ps.ActiveTab Is Nothing Then

                ps.ActiveTab = portalTab

            End If

            'Add each host Tab to DesktopTabs

            Dim hostTab As TabInfo = Nothing

            For Each tabPair As KeyValuePair(Of Integer, TabInfo) In tc.GetTabsByPortal(DotNetNuke.Common.Utilities.Null.NullInteger)

                ' clone the tab object ( to avoid creating an object reference to the data cache )

                hostTab = tabPair.Value.Clone()

                hostTab.PortalID = ps.PortalId

                hostTab.StartDate = System.DateTime.MinValue

                hostTab.EndDate = System.DateTime.MaxValue

                ps.DesktopTabs.Add(hostTab)

            Next


            'now add the portal settings to the httpContext

            If System.Web.HttpContext.Current Is Nothing Then

                'if there is no HttpContext, then mock one up by creating a fake WorkerRequest

                Dim appVirtualDir As String = DotNetNuke.Common.Globals.ApplicationPath

                Dim appPhysicalDir As String = AppDomain.CurrentDomain.BaseDirectory

                Dim page As String = ps.PortalAlias.HTTPAlias

                Dim query As String = String.Empty

                Dim output As System.IO.TextWriter = Nothing

                'create a dummy simple worker request

                Dim workerRequest As New System.Web.Hosting.SimpleWorkerRequest(page, query, output)

                System.Web.HttpContext.Current = New System.Web.HttpContext(workerRequest)

            End If

            'stash the portalSettings in the Context Items, where the rest of the DNN Code expects it to be

            System.Web.HttpContext.Current.Items.Add("PortalSettings", ps)

            Return ps

        End Function


Jeff Smith
VivoWare, Inc. - Open Source Social Networking Modules for DNN.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedSend out verification code and email programatically  Send out verification code and email programatically


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out