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

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Error when trying to programmatically send e-mail validation code to userError when trying to programmatically send e-mail validation code to user
Previous
 
Next
New Post
8/11/2010 9:00 PM
 
Hi,

I hope you can help me on this, but I'm having an error when trying to programmatically send a user validation e-mail to the user when he registers in the site. We are customizing the registration process because our client needs some customizations.

Attached is the code for the registration when he clicks the Create Account button:
Code

Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreate.Click

If Page.IsValid And capPostVideo.IsValid Then

Dim ui As New UserInfo

With ui

.IsSuperUser = False

.FirstName = txtFirstName.Text

.LastName = txtLastName.Text

.Username = txtUserName.Text

.DisplayName = txtFirstName.Text & IIf(txtMiddleName.Text <> "", " " & txtMiddleName.Text, "") & " " & txtLastName.Text

.Email = txtEmailAddr.Text

.Profile.InitialiseProfile(PortalId)

.Profile.PreferredLocale = PortalSettings.DefaultLanguage

.Profile.TimeZone = PortalSettings.TimeZoneOffset

.Profile.FirstName = txtFirstName.Text

.Profile.LastName = txtLastName.Text

.AffiliateID = -1

.Membership.Password = txtPassword.Text

.Membership.Approved = False

.PortalID = PortalId

End With

Dim objStatus As DotNetNuke.Security.Membership.UserCreateStatus = UserController.CreateUser(ui)

If objStatus = DotNetNuke.Security.Membership.UserCreateStatus.Success Then

Dim ps As PortalSettings = New PortalSettings(0)

DotNetNuke.Services.Mail.Mail.SendMail(ui, DotNetNuke.Services.Mail.MessageType.UserRegistrationVerified, ps)

MultiView1.ActiveViewIndex = 1

Label1.Text = objStatus.ToString()

Else

lblStatus.Text = objStatus.ToString

End If

End If

End Sub

When a user creates an account and clicks it, the user is added successfully, but this particular line registers an error in the event log as:

Event Viewer LogAssemblyVersion: 5.4.4
PortalID: 0
PortalName: My Website
UserID: 1
UserName: host
ActiveTabID: 65
ActiveTabName: NewReg
RawURL: /DNNTest/NewReg.aspx
AbsoluteURL: /DNNTest/Default.aspx
AbsoluteURLReferrer: http://localhost/DNNTest/NewReg.aspx
UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; Media Center PC 5.0; .NET CLR 3.0.30729)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 62bf9bfa-b723-4a16-8aa0-e419ede2cdc4
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.Entities.Portals.PortalSettings.GetProperty
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Portals.PortalSettings.GetProperty(String strPropertyName, String strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, Boolean& PropertyNotFound) at DotNetNuke.Services.Tokens.BaseCustomTokenReplace.replacedTokenValue(String strObjectName, String strPropertyName, String strFormat) at DotNetNuke.Services.Tokens.BaseTokenReplace.ReplaceTokens(String strSourceText) at DotNetNuke.Services.Localization.Localization.GetSystemMessage(String strLanguage, PortalSettings objPortal, String MessageName, UserInfo objUser, String ResourceFile, ArrayList CustomArray, IDictionary CustomDictionary, String CustomCaption, Int32 AccessingUserID) at DotNetNuke.Services.Mail.Mail.SendMail(UserInfo user, MessageType msgType, PortalSettings settings) at XSYS.Modules.CustomProfile.Register.btnCreate_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\DNNTest\DesktopModules\XSYS.CustomProfile\Register.ascx.vb:line 58 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
Source:
Server Name: XSYS-LAPTOP2

Hope you can help me out... is there anything that I missed on sending the email?

Thanks! 

 
New Post
8/12/2010 7:00 AM
 

Oops, looks like the text isn't displaying correctly ... I'm rewriting it as below:

Hi,

I hope you can help me on this, but I'm having an error when trying to programmatically send a user validation e-mail to the user when he registers in the site. We are customizing the registration process because our client needs some customizations.

Attached is the code for the registration when he clicks the Create Account button:
Code

Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreate.Click

If Page.IsValid And capPostVideo.IsValid Then

Dim ui As New UserInfo

With ui

.IsSuperUser = False

.FirstName = txtFirstName.Text

.LastName = txtLastName.Text

.Username = txtUserName.Text

.DisplayName = txtFirstName.Text & IIf(txtMiddleName.Text <> "", " " & txtMiddleName.Text, "") & " " & txtLastName.Text

.Email = txtEmailAddr.Text

.Profile.InitialiseProfile(PortalId)

.Profile.PreferredLocale = PortalSettings.DefaultLanguage

.Profile.TimeZone = PortalSettings.TimeZoneOffset

.Profile.FirstName = txtFirstName.Text

.Profile.LastName = txtLastName.Text

.AffiliateID = -1

.Membership.Password = txtPassword.Text

.Membership.Approved = False

.PortalID = PortalId

End With

Dim objStatus As DotNetNuke.Security.Membership.UserCreateStatus = UserController.CreateUser(ui)

If objStatus = DotNetNuke.Security.Membership.UserCreateStatus.Success Then

Dim ps As PortalSettings = New PortalSettings(0)

DotNetNuke.Services.Mail.Mail.SendMail(ui, DotNetNuke.Services.Mail.MessageType.UserRegistrationVerified, ps)

MultiView1.ActiveViewIndex = 1

Label1.Text = objStatus.ToString()

Else

lblStatus.Text = objStatus.ToString

End If

End If

End Sub

When a user creates an account and clicks it, the user is added successfully, but this particular line registers an error in the event log as:

Event Viewer LogAssemblyVersion: 5.4.4
PortalID: 0
PortalName: My Website
UserID: 1
UserName: host
ActiveTabID: 65
ActiveTabName: NewReg
RawURL: /DNNTest/NewReg.aspx
AbsoluteURL: /DNNTest/Default.aspx
AbsoluteURLReferrer: http://localhost/DNNTest/NewReg.aspx
UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; Media Center PC 5.0; .NET CLR 3.0.30729)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 62bf9bfa-b723-4a16-8aa0-e419ede2cdc4
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.Entities.Portals.PortalSettings.GetProperty
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Portals.PortalSettings.GetProperty(String strPropertyName, String strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, Boolean& PropertyNotFound) at DotNetNuke.Services.Tokens.BaseCustomTokenReplace.replacedTokenValue(String strObjectName, String strPropertyName, String strFormat) at DotNetNuke.Services.Tokens.BaseTokenReplace.ReplaceTokens(String strSourceText) at DotNetNuke.Services.Localization.Localization.GetSystemMessage(String strLanguage, PortalSettings objPortal, String MessageName, UserInfo objUser, String ResourceFile, ArrayList CustomArray, IDictionary CustomDictionary, String CustomCaption, Int32 AccessingUserID) at DotNetNuke.Services.Mail.Mail.SendMail(UserInfo user, MessageType msgType, PortalSettings settings) at XSYS.Modules.CustomProfile.Register.btnCreate_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\DNNTest\DesktopModules\XSYS.CustomProfile\Register.ascx.vb:line 58 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
Source:
Server Name: XSYS-LAPTOP2

Hope you can help me out... is there anything that I missed on sending the email?

Thanks!

 
New Post
8/12/2010 10:21 AM
 
Instead of:

Dim ps As PortalSettings = New PortalSettings(0)
DotNetNuke.Services.Mail.Mail.SendMail(ui, DotNetNuke.Services.Mail.MessageType.UserRegistrationVerified, ps)


try this:

Dim ps As PortalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings()
DotNetNuke.Services.Mail.Mail.SendMail(ui, DotNetNuke.Services.Mail.MessageType.UserRegistrationVerified, ps)


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
8/12/2010 12:06 PM
 
Hi Bill,

It worked wonders!!! Thanks a lot!!

I have another question though--I am also providing a customized registration via XML Web Services, and I used almost the same code I have in my original post. However I couldn't seem to use GetCurrentPortalSettings() on the web service--probably because I am not under a DotNetNuke context while in the webservice. Is there anything I can do to make this work when publishing Registration via web services?

Thanks again! You saved my life. :-)

Regards,
Jake
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Error when trying to programmatically send e-mail validation code to userError when trying to programmatically send e-mail validation code to user


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