打印下面的时候我会收到 while(oledr.Read()) Response.Write(smail); 打印下面的时候我会收到 while(oledr.Read()) Response.Write(smail); } I''m getting the email address from an excel sheet.But i need to send the email to multiple peopleWhen printing the below i [email protected];[email protected];;But i want [email protected];[email protected];i don''t need the extra semicolonThankscode below------while (oledr.Read()){smail = oledr[0].ToString() + ";" + "<br>";//smail += oledr[0].ToString() & ";";//mail.To.Add(smail);//this.Label1.Text = smail;Response.Write(smail);} 解决方案 Well, here you have a work around (it could be better coded, but this willwork for you), just add the semicolon before and in the first ocurrence don''tdo 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 peopleWhen printing the below i [email protected];[email protected];;But i want [email protected];[email protected];i don''t need the extra semicolonThankscode below------while (oledr.Read()){smail = oledr[0].ToString() + ";" + "<br>";//smail += oledr[0].ToString() & ";";//mail.To.Add(smail);//this.Label1.Text = smail;Response.Write(smail);} This code will always produce only the last email. It can be a bit correctedas:smail ="";while (oledr.Read()){if(smail.Length 0) smail += ";"smail += oledr[0].ToString();}--Eliyahu Goldin,Software DeveloperMicrosoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net"Braulio Diez" <br**************@yahoo.eswrote in messagenews:23**********************************@microsof t.com...Well, here you have a work around (it could be better coded, but this willwork for you), just add the semicolon before and in the first ocurrencedon''tdo 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 peopleWhen printing the below i [email protected];[email protected];;But i want [email protected];[email protected];i don''t need the extra semicolonThankscode below------while (oledr.Read()){smail = oledr[0].ToString() + ";" + "<br>"; //smail += oledr[0].ToString() & ";";//mail.To.Add(smail);//this.Label1.Text = smail;Response.Write(smail);} Thanks butTried what you suggested like thisbool firstTime = true;while (oledr.Read()){string smail;smail = "";if (!firstTime)smail = ";";//smail = oledr[0].ToString();smail += oledr[0].ToString();//mail.To.Add(smail);Response.Write(smail);}But didn''t solve the problem"Braulio Diez" <br**************@yahoo.eswrote in messagenews:23**********************************@microsof t.com...Well, here you have a work around (it could be better coded, but this willwork for you), just add the semicolon before and in the first ocurrencedon''tdo 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 peopleWhen printing the below i [email protected];[email protected];;But i want [email protected];[email protected];i don''t need the extra semicolonThankscode below------while (oledr.Read()){smail = oledr[0].ToString() + ";" + "<br>"; //smail += oledr[0].ToString() & ";";//mail.To.Add(smail);//this.Label1.Text = smail;Response.Write(smail);} 这篇关于使用sqldatareader发送电子邮件时如何获取正确的电子邮件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 02:37