471,082 Members | 708 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

Split Function

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail
Aug 14 '06 #1
5 2729
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?
sck10 wrote:
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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail
Aug 14 '06 #2
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" wrote:
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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail
Aug 14 '06 #3
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 [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:0B**********************************@microsof t.com...
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" wrote:
>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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail

Aug 14 '06 #4
This should work.

string to = "fr**@fred.com,ge****@george.com";
string[] SplitCatcher = to.split(',');

for (int i = 0; i<SplitCatcher.Length; i++)
{
if (SplitCatcher[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

sck10 wrote:
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 [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:0B**********************************@microsof t.com...
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" wrote:
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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail
Aug 14 '06 #5
Thanks Gozirra,

Works perfect...
"Gozirra" <rm********@hotmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
This should work.

string to = "fr**@fred.com,ge****@george.com";
string[] SplitCatcher = to.split(',');

for (int i = 0; i<SplitCatcher.Length; i++)
{
if (SplitCatcher[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

sck10 wrote:
>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 [C# MVP]" <pb*******@yahoo.nospammin.comwrote in
message
news:0B**********************************@microso ft.com...
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" wrote:

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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[i].Length 0) MM.To.Add(SplitCatcher[i]);
}

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

} //End void SendMail

Aug 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Arjen | last post: by
2 posts views Thread by SL_McManus | last post: by
4 posts views Thread by Henry Chen | last post: by
5 posts views Thread by Vamsi | last post: by
10 posts views Thread by mb | last post: by
4 posts views Thread by Itzik | last post: by
7 posts views Thread by Jordi Rico | last post: by
1 post views Thread by John | last post: by
reply views Thread by leo001 | last post: by

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.