473,545 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sma il);

//this.Label1.Tex t = smail;

Response.Write( smail);

}
Jun 27 '08 #1
11 1732
Well, here you have a work around (it could be better coded, but this will
work for you), just add the semicolon before and in the first ocurrence don't
do the concat:

bool firstTime = true;

while (oledr.Read())
{
smail ="";
if(!firstTime) smail = ";"
smail += oledr[0].ToString();
}

--
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"rote" wrote:
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(sma il);

//this.Label1.Tex t = smail;

Response.Write( smail);

}
Jun 27 '08 #2
This code will always produce only the last email. It can be a bit corrected
as:

smail ="";
while (oledr.Read())
{
if(smail.Length 0) smail += ";"
smail += oledr[0].ToString();
}

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Braulio Diez" <br************ **@yahoo.eswrot e in message
news:23******** *************** ***********@mic rosoft.com...
Well, here you have a work around (it could be better coded, but this will
work for you), just add the semicolon before and in the first ocurrence
don't
do the concat:

bool firstTime = true;

while (oledr.Read())
{
smail ="";
if(!firstTime) smail = ";"
smail += oledr[0].ToString();
}

--
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"rote" wrote:
>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(sma il);

//this.Label1.Tex t = smail;

Response.Write (smail);

}

Jun 27 '08 #3
Thanks but
Tried what you suggested like this
bool firstTime = true;

while (oledr.Read())

{

string smail;

smail = "";

if (!firstTime)sma il = ";";

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

smail += oledr[0].ToString();
//mail.To.Add(sma il);

Response.Write( smail);

}

But didn't solve the problem

"Braulio Diez" <br************ **@yahoo.eswrot e in message
news:23******** *************** ***********@mic rosoft.com...
Well, here you have a work around (it could be better coded, but this will
work for you), just add the semicolon before and in the first ocurrence
don't
do the concat:

bool firstTime = true;

while (oledr.Read())
{
smail ="";
if(!firstTime) smail = ";"
smail += oledr[0].ToString();
}

--
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"rote" wrote:
>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(sma il);

//this.Label1.Tex t = smail;

Response.Write (smail);

}

Jun 27 '08 #4
I'm getting multiple duplicate records using ur code?
any ideas

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:ef******** ******@TK2MSFTN GP02.phx.gbl...
This code will always produce only the last email. It can be a bit
corrected as:

smail ="";
while (oledr.Read())
{
if(smail.Length 0) smail += ";"
smail += oledr[0].ToString();
}

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Braulio Diez" <br************ **@yahoo.eswrot e in message
news:23******** *************** ***********@mic rosoft.com...
>Well, here you have a work around (it could be better coded, but this
will
work for you), just add the semicolon before and in the first ocurrence
don't
do the concat:

bool firstTime = true;

while (oledr.Read())
{
smail ="";
if(!firstTim e) smail = ";"
smail += oledr[0].ToString();
}

--
/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------


"rote" wrote:
>>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(sma il);

//this.Label1.Tex t = smail;

Response.Writ e(smail);

}


Jun 27 '08 #5
"rote" <na********@hot mail.comwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
Response.Write( smail);
Response.Write( smail.TrimEnd(' ;'));
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #6
Error
The specified string is not in the form required for an e-mail address.
is it "; "or ", "
tried all with no success
Using
using System.Net.Mail ;

Anu ideas this is driving me nuts

Thanks Mark

[MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:eu******** ******@TK2MSFTN GP04.phx.gbl...
"rote" <na********@hot mail.comwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
>Response.Write (smail);

Response.Write( smail.TrimEnd(' ;'));
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #7
Fantastic.Never paid attention to this method.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:eu******** ******@TK2MSFTN GP04.phx.gbl...
"rote" <na********@hot mail.comwrote in message
news:uB******** ******@TK2MSFTN GP03.phx.gbl...
>Response.Write (smail);

Response.Write( smail.TrimEnd(' ;'));
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #8
"rote" <na********@hot mail.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Error
The specified string is not in the form required for an e-mail address.
is it "; "or ", "
tried all with no success
Using
using System.Net.Mail ;

Any ideas this is driving me nuts
Oh right - now I see what you're trying to do...

while (oledr.Read())
{
mail.To.Add(ole dr[0].ToString());
}

http://www.systemnetmail.com/faq/3.2.3.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #9
Thanks but when i do that i get error:
The parameter 'addresses' cannot be an empty string.
Parameter name: addresses

"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
"rote" <na********@hot mail.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Error
The specified string is not in the form required for an e-mail address.
is it "; "or ", "
tried all with no success
Using
using System.Net.Mail ;

Any ideas this is driving me nuts

Oh right - now I see what you're trying to do...

while (oledr.Read())
{
mail.To.Add(ole dr[0].ToString());
}

http://www.systemnetmail.com/faq/3.2.3.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7029
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt. Obviuosly, the file is fine on the server, so the attachment code I am using must be corrupting it, but I dont know what it is: // send email with...
4
1640
by: Nathan Sokalski | last post by:
I have a form which will be processed by being sent to an ASP page. I would like the ASP page to take the data from the Request.QueryString (which I know how to do) and format it so I can have it emailed to me in a nicer format. My problem is that I do not know how to have ASP send an email. I know how to send an email using the mailto:...
2
21075
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. 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. ...
1
1441
by: Emmanuel | last post by:
hi, i want to make a tool which automates email replies. How can i include the original message body in my reply using the same format as a normal email client would do, in both html and text formats? Are there standards on this? example, if i look at what MS outllok does to the body, would it be supported in all email clients? thanks!
7
16571
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked around in the MS/ACCESS Help facility and found that I can click on FILE (on the Menu Bar) and then click on SEND TO. This will generate, either, a...
2
9257
by: Rich | last post by:
Hello, I need to send an automated email message from my application (vb2005) - using system.net.mail. What I need to do to the message is to format the text, like underlining, bolding, changing font colors. I can send the message OK with the default font senttings. But how can I customize the fonts/Text? Thanks, Rich
14
11869
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was doing something was really inefficient and could reduce 10 lines of code with 2, etc. For reading, I am using a TcpClient and I call ...
1
875
by: arial | last post by:
Hi all, I am getting this error message and I don't know why? Input string was not in a correct format. 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:...
3
1761
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only one dot in the domain name (eg : test@abc.com) there are no issues. but when the mail ids are like (test@abc.co.in or test@abc.rr.com) the mail is...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7756
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5326
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.