Split Function

S

sck10

Hello,

I have a list of email addresses that I need to send email to from the
website. I am trying to use the "Split" function to get all the To's and
then use the uBound function for the For-Loop limit:

I am trying to convert the following from vb to c#:

Dim SplitCatcher As Object
SplitCatcher = Split(To, ",")

Dim i As Integer
For i = 0 To UBound(SplitCatcher)
If Len(SplitCatcher(i)) > 0 Then objMM.To.Add(SplitCatcher(i))
Next

to

string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}



Mail Code
====================
public void SendWebMail(string From, string To, string Subject, string Body,
string Client)
{
//Build Email List
MailMessage MM = new MailMessage();
MailAddress AddrFrom = new MailAddress(From);

// build recipient list
//MailAddress AddrTo = new MailAddress(To);
string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}

MM.Subject = Subject;
MM.Body = Body;
SmtpClient scMail = new SmtpClient(Client);
scMail.Send(MM);

} //End void SendMail
 
K

Karl

I take it you have another closing curly brace at the end of your code
as there appears to be one missing from here.

Also, what exactly is your error?
 
S

sck10

Thanks,
For the Split function, I am getting the error: The name 'Split' does not
exist in the current context.

Thanks for your help with this.

sck10


Peter Bromberg said:
No "ubound" in C#!

for (int i = 0; i<SplitCatcher.Length; i++)

Cheers,
Peter


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




sck10 said:
Hello,

I have a list of email addresses that I need to send email to from the
website. I am trying to use the "Split" function to get all the To's and
then use the uBound function for the For-Loop limit:

I am trying to convert the following from vb to c#:

Dim SplitCatcher As Object
SplitCatcher = Split(To, ",")

Dim i As Integer
For i = 0 To UBound(SplitCatcher)
If Len(SplitCatcher(i)) > 0 Then objMM.To.Add(SplitCatcher(i))
Next

to

string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}



Mail Code
====================
public void SendWebMail(string From, string To, string Subject, string
Body,
string Client)
{
//Build Email List
MailMessage MM = new MailMessage();
MailAddress AddrFrom = new MailAddress(From);

// build recipient list
//MailAddress AddrTo = new MailAddress(To);
string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}

MM.Subject = Subject;
MM.Body = Body;
SmtpClient scMail = new SmtpClient(Client);
scMail.Send(MM);

} //End void SendMail
 
G

Gozirra

This should work.

string to = "(e-mail address removed),[email protected]";
string[] SplitCatcher = to.split(',');

for (int i = 0; i<SplitCatcher.Length; i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}
Thanks,
For the Split function, I am getting the error: The name 'Split' does not
exist in the current context.

Thanks for your help with this.

sck10


Peter Bromberg said:
No "ubound" in C#!

for (int i = 0; i<SplitCatcher.Length; i++)

Cheers,
Peter


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




sck10 said:
Hello,

I have a list of email addresses that I need to send email to from the
website. I am trying to use the "Split" function to get all the To's and
then use the uBound function for the For-Loop limit:

I am trying to convert the following from vb to c#:

Dim SplitCatcher As Object
SplitCatcher = Split(To, ",")

Dim i As Integer
For i = 0 To UBound(SplitCatcher)
If Len(SplitCatcher(i)) > 0 Then objMM.To.Add(SplitCatcher(i))
Next

to

string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}



Mail Code
====================
public void SendWebMail(string From, string To, string Subject, string
Body,
string Client)
{
//Build Email List
MailMessage MM = new MailMessage();
MailAddress AddrFrom = new MailAddress(From);

// build recipient list
//MailAddress AddrTo = new MailAddress(To);
string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}

MM.Subject = Subject;
MM.Body = Body;
SmtpClient scMail = new SmtpClient(Client);
scMail.Send(MM);

} //End void SendMail
 
S

sck10

Thanks Gozirra,

Works perfect...


Gozirra said:
This should work.

string to = "(e-mail address removed),[email protected]";
string[] SplitCatcher = to.split(',');

for (int i = 0; i<SplitCatcher.Length; i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}
Thanks,
For the Split function, I am getting the error: The name 'Split' does not
exist in the current context.

Thanks for your help with this.

sck10


message
No "ubound" in C#!

for (int i = 0; i<SplitCatcher.Length; i++)

Cheers,
Peter


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

Hello,

I have a list of email addresses that I need to send email to from the
website. I am trying to use the "Split" function to get all the To's
and
then use the uBound function for the For-Loop limit:

I am trying to convert the following from vb to c#:

Dim SplitCatcher As Object
SplitCatcher = Split(To, ",")

Dim i As Integer
For i = 0 To UBound(SplitCatcher)
If Len(SplitCatcher(i)) > 0 Then objMM.To.Add(SplitCatcher(i))
Next

to

string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}



Mail Code
====================
public void SendWebMail(string From, string To, string Subject, string
Body,
string Client)
{
//Build Email List
MailMessage MM = new MailMessage();
MailAddress AddrFrom = new MailAddress(From);

// build recipient list
//MailAddress AddrTo = new MailAddress(To);
string[] SplitCatcher = Split(To, ",");
for (int i = 0; uBound(SplitCatcher); i++)
{
if (SplitCatcher.Length > 0) MM.To.Add(SplitCatcher);
}

MM.Subject = Subject;
MM.Body = Body;
SmtpClient scMail = new SmtpClient(Client);
scMail.Send(MM);

} //End void SendMail

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top