how to get the correct email format when sending email using sqldatareader

I'm getting the email address from an excel sheet.
But i need to send the email to multiple people
When printing the below i get
a@a.com;b@b.com;;

But i want a@a.com;b@b.com;

i don't need the extra semicolon

Thanks

code below
------

while (oledr.Read())

{

smail = oledr[0].ToString() + ";" + "<br>";

 

//smail += oledr[0].ToString() & ";";

//mail.To.Add(smail);

//this.Label1.Text = smail;

Response.Write(smail);

}

 

0
naijacoder74
4/16/2008 4:50:45 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

7 Replies
1094 Views

Similar Articles

[PageSpeed] 2

If oledr[0].ToString() contains only one email address (and not a few), then you can do it this way:

while (oledr.Read())
{
   if(oledr[0].ToString() != string.Empty)
      smail = oledr[0].ToString() + ";" + "&lt;br>";
   Response.Write(smail);
}
 
May the Force be with you
0
nKognito
4/16/2008 5:24:00 AM

Thanks nkognito but it contains a few

0
naijacoder74
4/16/2008 6:01:37 AM

Two ways:

1. It contains string like: a@a.com;b@b.com; - in this case you shouldn't add an additional semi-colon at the end

2. It contains string like: a@a.com;b@b.com - in this case you should add semi-colon at the end

What you can to do: after generating a final string (in your case - smail) use string.Replace() method to remove all double semi-colons: smail.Replace(";;", ";");


May the Force be with you
0
nKognito
4/16/2008 6:59:02 AM

 Hi,

 

Its so simple

write one statement after while loop

if smail is your string than .. 

like this..

 smail = smail.Substring(0,smail.Length -1 );

 

it removes last character from your smail string...

 

ifyou get your answer than please ... "Mark as Answer" 

 


Jigar Patel
Web Developer
India
0
Jigarpatel
4/16/2008 7:14:09 AM

THanks guys but i can see i have correct email dd@yahoo.com; 1978@yahoo.com; printed out but keep getting error

The specified string is not in the form required for an e-mail address.

while (oledr.Read())

{

string smail = oledr[0].ToString();

if (smail != string.Empty)

smail = oledr[0].ToString() + "; ";

//smail = oledr[0].ToString() + ";" + "<br>";

//smail += oledr[0].ToString() & ";";

mail.To.Add(smail);

//this.Label1.Text = smail;

//smail = smail.Substring(0, smail.Length - 1);

 

Response.Write(smail);

}

0
naijacoder74
4/16/2008 9:14:52 AM

 Hi,

Use "," Character in place of ";",

try out this ..

it may works

 

got the solution then "Mark as Answer" 


Jigar Patel
Web Developer
India
0
Jigarpatel
4/16/2008 9:26:56 AM

No luck Sad

Also why do i get error :

StartIndex cannot be less than zero.
Parameter name: startIndex

while (oledr.Read())

{

string smail = oledr[0].ToString();

if (smail != string.Empty)

smail += oledr[0].ToString() + ",";

smail = smail.Remove(smail.Length - 1);

Response.Write(smail);

}

0
naijacoder74
4/16/2008 9:38:18 AM
Reply:

Similar Artilces:

A problem to send email using Smtp
I have a proble to send an email from asp.net I do the following code to send an email: MailMessage mail=new MailMessage(); mail.From="test@server.com"; mail.To="myemailaddress@server.com"; mail.BodyFormat=MailFormat.Html; mail.Subject="testing..."; mail.Body="cool"; SmtpMail.SmtpServer="localhost"; SmtpMail.Send(mail); But I dont' receive an email when I use this method. Why is that? How can I send an email? Thanks in advance! check and see if.. -your client-side code has no errors -you imported the S...

Get email address from DB and send email using VB
OK every time I figure something out on my own, there's 10 more things I can't seem to figure out. I feel like a VB moron. Ha. Anyway. Here's what I need to do...1. Retrieve the email addresses from my database table of people whose memberships to my organization has expired in the past month.2. Somehow plug those email addresses into a code to send them a prewritten, preformatted email.I have found an article on how to send an email using VB coding. I just don't know how I would send one email to every person whose membership has expired in the past month. Ideally, I'd like to be able to lo...

Get email suffix (.net, .org, etc...) from email using Regular Expressions
Does anyone have a code snippet that could do this in VB.NET? I want it to return .net if given bob@microsoft.net Thanks, ScAndal.NET Web Based CRM http://www.kineticcrm.com.NET Consulting http://www.kineticmedia.net Hm. Well, I can get you started, but it won't handle sub-domain e-mails. To make this example easier for me to think about, this regex will look for: someword@someword.some.more.words (Why ".some.more.words"? Because of international country extensions) And it will save the ".some.more.words" part in the Groups property of the Match in in...

Creating Email Alias which would send email to select email accounts using HMC 4.0
Hello all,   I was wondering what is the best method of creating a email alias in exchange 2007. I tried using exchange 2007 console, but it seems the only way is to add the smtp address to each user. I did try a group, but it add's the default smtp address which I do not want there, and it complains when I try to remove it. I was wondering if there is a way from provision or exchange console....

How can I send an HTML format email using send mail
Does anyone know how to send an HTML formatted email using sendmail. I can send plain text email OK. If I format the message using HTML the message shows the HTML tags. I can't find any information regarding this on cpan. Are there any other modules that have this capability? Any help is greatly appreciated. Jeff I've sent you a private message with a script. I didn't think it would be appropriate to post that much code to the list. Agustin Rivera Webmaster, Pollstar.com http://www.pollstar.com ----- Original Message ----- From: "jeff" <we...

Using ALTAS to Send Email (Email Form)
Hello all. I have yet to find anywhere an example on how one might use the underlying ATLAS API (not the fancy controls that come with it) to send a simple email from a simple webform. Can anyone point one out for me? Or maybe someone has an example tucked away somewhere that they might want to let out ino the public? Thanks,Andrew There is nothing special about sending e-mail with "Atlas". On the client you can use a link with the "mailto:" pseudo protocol, to fire up the default e-mail client. See mailto protocol for more information.On the server you can use the features in the Syste...

Using Email Interface
Hi-- I recently set up a version of Bugzilla for my company (v 3.0.2) and I want to use the email interface so I can submit bugs via email. I know how to format an email in order to do this, but I don't know what email address to send it to. Where do I find this email address/how can I set it up? Thanks rmandal@gmail.com wrote: > Hi-- > > I recently set up a version of Bugzilla for my company (v 3.0.2) and I > want to use the email interface so I can submit bugs via email. I know > how to format an email in order to do this, but I don't know what &g...

Sending Email with Net.Mail (No Email, no error)
hi,i'm using the system.net.Mail namespace to send an email from my application. when i send, the application does not fire any exception, neither does it send the email to my account.below is the code i'm using  Dim mmailMessage As New Net.Mail.MailMessage Dim mFrom As New Net.Mail.MailAddress(mailFrom) mmailMessage.From = mFrom Dim ll As String = "myname@ourmail.com" mmailMessage.To.Add(ll) mmailMessage.Subject = "Talk Concerns" mmailMessage.Body = "Testing Concerns One Two" Dim ...

Sending an email using .net
Hi, I am using SMTP Mail object in vb.net to send off an email. Everything works fine most of the times but sporadically it sends the same messsage more than one time. It creates a lot of confusion to the users. I debugged the application and the line "clsMail.Send(clsMailMessage)', where clsMail is an object of SmtpMail and clsMailMessage is an object of MailMessage, runs only once but still my inbox has same email more than once. Please suggest me . Regards, Prerak Are you sure that you are not submiting your page multiple times or refreshing the page?Pandora Tomorrow ...

Use the email adress in the users profile to send an email
Hi, hope you cn help me. I am using the createuserwizard to create new users. In this template the users are asked for their email adress. All is working fine, but how can I use the email adress the user entered during registration later in a session to send him an email? I thought just "profile.email", but its wrong.   Hope you can help me, Chrissi Hi Chrissi, When you use the CreateUserWizard, you're creating a user through the current membership provider, which is different than Profiles.  To get a user's email, tryDim myUser As System.Web.Security.Mem...

Getting email address in gridview row and send email
Hi guys, How do i get the email address in my gridview rows?  I wanna get all the email address of all of my records in the gridview and use the email address to send an email to the owner. Thanks,*A newbie C# programmer* hi have a look at threse related : http://forums.asp.net/p/1119999/1746089.aspx#1746089http://forums.asp.net/t/1062163.aspxhttp://www.velocityreviews.com/forums/t93436-gridview-hyperlink-column-mailto-event.html Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (l...

Sending HTML Email Using EMAIL::MIME::CreateHTML
------_=_NextPart_001_01C7D5F2.CEEC49EF Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am using the Email::MIME:CreateHTML module to send html formatted emails. It all works fine until I try to change the "To" line to a scalar so that I can mass mail to different individuals. Has anyone used this module in a manner like this before? Thanks, my $email =3D travis_hervey@georgetowncollege.edu; while(<DAT>) { $line =3D TRIM($_); $html =3D $html . $_; if($line eq "</b...

hide email addresses from email after using smtp.send()
hello , I have some kind of subscribe feature , the emails are saved in database so am using a sqldatareader and a loop , inside loop am adding the emails with msg.to.add() , but what is happening that all the emails are being shown ( in the to place) when a subscriber receives an email , but I dont want that , cause the subscriber shall not know email addresses of other subscribers , how to fix this thing ?!? thanks alot place all the recipients on the BCC of the email. this prevents them from seeing the email of other BCC recipients  Mike Banavige~~~~~~~~~~~~Need...

I've not be able to use my Firefox email lately because of a required password to get into it, which I do not have. So, I have had to go to Yahoo to get an email program. Is there a way to recover
Name: Billl Brewster Email: billb7824atcharterdotnet Product: Firefox Summary: I've not be able to use my Firefox email lately because of a required password to get into it, which I do not have. So, I have had to go to Yahoo to get an email program. Is there a way to recover whatever password got registered to my Firefox account? Comments: Thank you. See note in summary. Bill Brewster billb7824@charter.net Browser Details: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC ...

Web resources about - how to get the correct email format when sending email using sqldatareader - asp.net.object-datasource

Bazaar - Alternative Windows Phone marketplace for homebrew applications DotNetNuke
Message: System.Data.SqlClient.SqlException (0x80131904): Could not allocate space for object 'dbo.EventLog'.'PK_EventLogMaster' in database ...

S&N Hotel Reservation Website
S&N Hotel Reservation Website

遵义人力资源和社会保障网
遵义市人力资源和社会保障局官方网站

C# dotnet SQL Editor (webform side)
Every time I need to develop a small business application I always try to choose the fastest and simplest way to implement it. This is why I ...

Software Review -Visual Studio 2008: Professional Edition From Microsoft
Visual Studio 2008: Professional Edition is the latest incarnation of the integrated development environment (IDE) from Microsoft Corporation. ...

DotNetNuke
Message: System.Data.SqlClient.SqlException (0x80131904): Could not allocate space for object 'dbo.EventLog'.'PK_EventLogMaster' in database ...

How to prevent SQL Injection in APS.NET
protected void Login_Click ( object sender, EventArgs e ) { using ( SqlConnection cn = new SqlConnection ( "data source=localhost;initial catalog=Test;user ...

Loading objects' fields/properties automagically
... and useful. So I did what any good dev would, I read the sourcecode and derived my own functions to do something similar, but with the SqlDataReaders ...

.NET ORM Dapper released as open source
Dapper is the new object relational mapper behind the Stack Overflow site and is designed to be a simple way of extending database connections ...

Simple CRUD with Silverlight 2.0
I spent a couple of hours putting together a simple CRUD (Create, Retrieve, Update, Delete) application with Silverlight 2.0 Beta 2. Most of ...

Resources last updated: 11/26/2015 10:27:42 AM