473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 2867
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Arjen | last post by:
Hi All, What I want to is using a string as PATTERN in a split function. This makes it possible for me to change the PATTERN on one place in my script... For example: $separator = ";"; $line...
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
10
by: mb | last post by:
I was wondering if there is an easy, more useful Split function that will split with a string delimiter like "<>" or "////"?
4
by: Itzik | last post by:
can i split this string string str = "aa a - bb-b - ccc" with this delimiter string del = " - " i want recieve 3 items : "aa a" , "bb-b" , "ccc"
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
7
by: Jordi Rico | last post by:
Hi, I know I can split a string into an array doing this: Dim s As String()=Regex.Split("One-Two-Three","-") So I would have: s(0)="One" s(1)="Two"
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.