使用sqldatareader发送电子邮件时如何获取正确的电子邮件格式 [英] how to get the correct email format when sending email using sqldatareader

查看:103
本文介绍了使用sqldatareader发送电子邮件时如何获取正确的电子邮件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从excel表中获取电子邮件地址。

但我需要将电子邮件发送给多个人

当打印下面的时候我得到了
$ b$ba @ a.com; b@b.com ;;


但我想要a@a.com; b@b.com;
< br $>
i不需要额外的分号


谢谢


以下代码

------


while(oledr.Read())


{


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


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


//mail.To.Add(smail);


//this.Label1.Text = smail ;


Response.Write(smail);


}

解决方案

嗯,这里你有一个解决方法(它可以更好地编码,但这将为你工作
),只需在第一次出现之前和第一次出现时添加分号

做concat:


bool firstTime = true;


while(oledr.Read())

{

smail ="" ;;

if(!firstTime)smail =" ;;"

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

}


-

/// ---- --------------------------

/// Braulio Diez

///

/// http://www.tipsdotnet.com

/// ------------------------------



" rote"写道:


我从excel表中获取电子邮件地址。

但我需要将电子邮件发送给多个人

打印下面的时候我得到了
$ b$ba@a.com; b@b.com ;;


但是我想要一个@ a.com; b@b.com;


i不需要额外的分号


谢谢

以下代码

------


while(oledr.Read())


{


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


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


//mail.To.Add(smail);


//this.Label1.Text = smail ;


Response.Write(smail);


}


< blockquote>此代码将始终只生成最后一封电子邮件。它可以稍微纠正

as:


smail ="" ;;

while(oledr.Read() )

{

if(smail.Length 0)smail + =" ;;"

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

}


-

Eliyahu Goldin,

软件开发人员
Microsoft MVP [ASP.NET]
http:// msmvps。 com / blogs / egoldin
http://usableasp.net

" Braulio Diez" < br ************** @ yahoo.eswrote in message

news:23 **************** ****************** @ microsof t.com ...


嗯,这里有一个解决方法(它可以更好地编码,但这将为你工作
),只需在第一次出现之前和之后添加分号

不要

做concat:


bool firstTime = true;


while(oledr.Read())

{

smail ="" ;;

if(!firstTime)smail =";"

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

}


-

/// -------- ----------------------

/// Braulio Diez

///

/// http://www.tipsdotnet.com

/// ------------------------------



死记硬背写道:


>我从excel表中获取电子邮件地址。
但我需要将电子邮件发送给多个人打印下面的时候我会收到
a@a.com; b@b.com ;;

但我想要a@a.com; b@b.com;

我不需要额外的分号

谢谢

下面的代码
------
while(oledr.Read())

{

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

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

//mail.To.Add(smail);

//this.Label1.Text = smail;
Response.Write(smail);

}



谢谢,但

尝试过这样的建议

bool 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 );


}


但是没有解决问题


" Braulio迭" < br ************** @ yahoo.eswrote in message

news:23 **************** ****************** @ microsof t.com ...


嗯,这里有一个解决方法(它可以更好地编码,但这将为你工作
),只需在第一次出现之前和之后添加分号

不要

做concat:


bool firstTime = true;


while(oledr.Read())

{

smail ="" ;;

if(!firstTime)smail =";"

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

}


-

/// -------- ----------------------

/// Braulio Diez

///

/// http://www.tipsdotnet.com

/// ------------------------------



死记硬背写道:


>我从excel表中获取电子邮件地址。
但我需要将电子邮件发送给多个人打印下面的时候我会收到
a@a.com; b@b.com ;;

但我想要a@a.com; b@b.com;

我不需要额外的分号

谢谢

下面的代码
------
while(oledr.Read())

{

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

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

//mail.To.Add(smail);

//this.Label1.Text = smail;
Response.Write(smail);

}



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);

}

解决方案

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(smail);

//this.Label1.Text = smail;

Response.Write(smail);

}


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.eswrote in message
news:23**********************************@microsof t.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(smail);

//this.Label1.Text = smail;

Response.Write(smail);

}



Thanks but
Tried what you suggested like this
bool 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 message
news:23**********************************@microsof t.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(smail);

//this.Label1.Text = smail;

Response.Write(smail);

}



这篇关于使用sqldatareader发送电子邮件时如何获取正确的电子邮件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆