Email sending issue

Topics: Developer Discussion, Help, Request
Jun 23, 2007 at 4:40 PM
I can login as admin and send an email to administrator ok but receive this error when trying to send an email to all the members.

The specified string is not in the form required for an e-mail address.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: The specified string is not in the form required for an e-mail address.

Source Error:



Line 147: name = "-"
Line 148: End If
Line 149: Dim address As New MailAddress(mem.Email, name)
Line 150: Dim user As MembershipUser = Membership.GetUser(gui)
Line 151: Dim da As New DataSetTableAdapters.MemberInfoTableAdapter


Source File: F:\HostingSpaces\jerrysdean43@msn.com\sahcinfo.org\wwwroot\Admin\Email.aspx.vb Line: 149
Coordinator
Jun 23, 2007 at 5:05 PM
Is someone's email address not specified?
Jun 23, 2007 at 8:23 PM

z2bass wrote:
Is someone's email address not specified?


All members have an email address specified.
Coordinator
Jun 23, 2007 at 11:20 PM
It looks like someone's email is not entered correctly... "The specified string is not in the form required for an e-mail address"
Jun 24, 2007 at 12:53 AM

z2bass wrote:
It looks like someone's email is not entered correctly... "The specified string is not in the form required for an e-mail address"


I found an incorrect email format, corrected it and am now receiving this error:

There is no row at position 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: There is no row at position 0.

Source Error:


Line 384: Public Default ReadOnly Property Item(ByVal index As Integer) As MemberInfoRow
Line 385: Get
Line 386: Return CType(Me.Rows(index),MemberInfoRow)
Line 387: End Get
Line 388: End Property


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2c13a4fc\91944b83\AppCode.gtbzj_r.10.vb Line: 386

Stack Trace:


IndexOutOfRangeException: There is no row at position 0.
System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) +1880026
System.Data.DataRowCollection.get_Item(Int32 index) +14
MemberInfoDataTable.getItem(Int32 index) in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2c13a4fc\91944b83\AppCode.gtbzjr.10.vb:386
Admin_Email.GetRecipients() in F:\HostingSpaces\jerrysdean43@msn.com\sahcinfo.org\wwwroot\Admin\Email.aspx.vb:153
AdminEmail.btnSendClick(Object sender, EventArgs e) in F:\HostingSpaces\jerrysdean43@msn.com\sahcinfo.org\wwwroot\Admin\Email.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102


Coordinator
Jun 24, 2007 at 2:19 AM
Looks like there is a problem with ASP.NET Membership.
Jun 25, 2007 at 1:30 PM

z2bass wrote:
Looks like there is a problem with ASP.NET Membership.


Do you have any suggestions? Did I mention that the email works fine if I just send to administrator, the problem occurs when trying to send to all members?
Mar 16, 2008 at 4:38 PM
Edited Mar 16, 2008 at 4:43 PM
We had the same issue in our site and found out it was a database issue. From my findings, somehow a user account can be created for the site, populating the dbo.aspnet_Users table in the DB, but for certain users it didn't populate the dbo.MemberInfo table. This caused the user information to be incomplete and I guess the Send Email function needs something in the dbo.MemberInfo table to send emails. To fix the issue I deleted the users account and asked them to re-register to the website. Before doing that I created a Foreign Key Relationship between the two tables in the database.

I'm guessing the error stems from perhaps a glitch in network traffic when a user is registering. If they don't get to the second screen where they enter their name, address, phone, etc... the dbo.MemberInfo table doesn't become populated and that is when you start having issued sending emails to registered users if that account is included in the security\distribution group you are sending the email to.
May 2, 2008 at 10:25 PM

spatzengr wrote:
We had the same issue in our site and found out it was a database issue. From my findings, somehow a user account can be created for the site, populating the dbo.aspnet_Users table in the DB, but for certain users it didn't populate the dbo.MemberInfo table. This caused the user information to be incomplete and I guess the Send Email function needs something in the dbo.MemberInfo table to send emails. To fix the issue I deleted the users account and asked them to re-register to the website. Before doing that I created a Foreign Key Relationship between the two tables in the database.

I'm guessing the error stems from perhaps a glitch in network traffic when a user is registering. If they don't get to the second screen where they enter their name, address, phone, etc... the dbo.MemberInfo table doesn't become populated and that is when you start having issued sending emails to registered users if that account is included in the security\distribution group you are sending the email to.



Thanks for the post. I found it as I was debugging, and it saved me a lot of time.
Aug 11, 2008 at 3:32 PM
Is there any other way to fix the "IndexOutOfRangeException: There is no row at position 0." problem without deleting all of the members and having them re-sign up?
How would one add the necessary data directly into the DB? Do we know what info the send mail function is taking from the memberinfo table that it needs to complete the send?
I have this same problem but would really like to avoid deleting the entire membership.

Thanks
Aug 13, 2008 at 1:00 AM
Yeah, you just need to look through the DB and make sure there is a row in the "MemberInfo" table that corresponds with a row in the "aspnet_Users" table for each user.
Aug 13, 2008 at 4:00 AM
How exactly did you join the two tables together using Visual Web Developer 2008?
Aug 13, 2008 at 10:58 AM
Edited Aug 13, 2008 at 11:05 AM
You are not joining the tables. If your site is live I don't think you are using Visual Web Developer (VWD) to edit the live database (DB) anymore. With my provider I use SQL Server Management Studio Express to connect to and edit the live DB.  BUT, that said if you are somehow using VDW to edit your live DB rather than you local test DB OR you are using some other program you can do the same thing.  I wish we could upload screen shots with this discussion engine but I will do my best to explain.

1). In VDW (or whatever program) open the "Database Explorer" palette (make sure you are connecting to your live DB.  This step may very with use of another program like SQL Sever Management Studio Express)
2). Open your DB (whichever program you are using get your DB open)
3). Open the "Tables" folder
4). Right-Click on the "aspnet_Users" table and CLICK "Show Table Data"
5). For each users that signs-up to the site there is a row created and a corresponding "UserId" number that is generated by ASP.NET for the users.  It is some crazy long alpha-numeric number.  Try to print a list of this data or just keep open to cross reference.
6). Proceed now to the "MembersInfo" table and Right-Click and SELECT "Show Table Data" as well...
7). Look at the column "memberid"
8). In the "MembersInfo" table there needs to be a corresponding row for each user in the "aspnet_Users" table.  The "membersid" column must match the "usersid" column from the "aspnet_Users" table (alpha-numberic numbers must match).
9). Delete or add rows to complete the tables and make them match. This could be dificult but just enter some data if you don't have specifics or delete the users all together and ask them to sign-up again.  I think the mismatch happens through deleting users OR if they get an error midway through signing up due to slow internet traffic

I think there can be more entries in the "MembersInfo" table than in the "aspnet_Users" table and that is OK but not the other way around.

Hope this helps...
mspatz
Aug 13, 2008 at 3:20 PM

As an update, I used SQL Management Server Management Studio Express to explore the Users and MembersInfo table and make sure there was an entry for each member of the Users table in the MembersInfo table.

This corrected the problem and everything seems to be working. As mspatz pointed out there can be more entries in Membersinfo table than than in Users table.

Thanks.