• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 881
  • Last Modified:

Send LN mail to multiple address from asp.net

I want to be able to send mail to more than one mail address from asp.net (vb code behind) application. I have mail addresses as TeboxBox.Text (four text box controls) and dont know how to add them to SendTo item in code.

Call doc.ReplaceItemValue("SendTo", Textbox1.Text.Trim)

Thanks.
0
kahvedzic
Asked:
kahvedzic
  • 5
  • 5
  • 3
1 Solution
 
mbonaciCommented:
Simply create an array, fill it with elements of the Textbox1 and place it in the method call, instead of Textbox1.Text.Trim param.
0
 
kahvedzicAuthor Commented:
OK but how to separate addresses in array only with "," or ", " or ";" (without "" of course)?
0
 
mbonaciCommented:
I don't understand, how do you mean "separate adresses in array"?

You don't.
I mean, you separate them by assigning them to different array positions:

array(0) = "addr1"
array(1) = "addr2"
array(2) = "addr3"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
BuggyCoderCommented:
if you have all the addresses in array, then do the following:-

string addList=String.join(",",yourarrref);
you will get comma separated address list in addlist variable.

here is how join works:-0
http://msdn.microsoft.com/en-us/library/57a79xd0.aspx

hope it helps
:-)
0
 
kahvedzicAuthor Commented:
This way if I want to send one mail to 4 people I have 4 mails in sent folder. This is not what I want, I want to send one mail to 4 people and in only one mail (like in Lotus Notes client in To text box it goes Person1@blabla.com, Person2@blabla.com, Person3@blabla.com etc....).
0
 
BuggyCoderCommented:
In my example above, just copy the addlist string value in the to address field. If you assign comma separated list to the TO address field it will send one mail to all the 4 addresses and u have only 1 mail in ur sent items.
0
 
mbonaciCommented:
No, you don't send a String to SendTo field when you want multiple recipients, you send an array.

Have you tried that?

Can I ask where are you from? I mean, which country?
0
 
kahvedzicAuthor Commented:
This is what I code:

Dim slanje As New ArrayList()

slanje.Add(adresa.Text.Trim)
slanje.Add(Label1.Text.Trim)
slanje.Add(Label2.Text.Trim)

Call doc.ReplaceItemValue("SendTo", slanje)

and then got:

Unknown or unsupported object type in Vector
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Unknown or unsupported object type in Vector

Source Error:


Line 39:         doc = db.CreateDocument
Line 40:         Call doc.ReplaceItemValue("Form", "Memo")
Line 41:         Call doc.ReplaceItemValue("SendTo", slanje)
Line 42:         Call doc.ReplaceItemValue("CopyTo", cc.Text.Trim)
Line 43:         Call doc.ReplaceItemValue("Subject", subject.Text.Trim)
0
 
mbonaciCommented:
Not a List, you need ordinary, simple, "non-object", array of strings.
ArrayList is List, not an array.

Can you write (in whatever language you're using, VB?):

Dim slanje(2) As String

slanje(0) = adresa.Text.Trim
slanje(1) = Label1.Text.Trim
slanje(2) = Label2.Text.Trim


No answer about the country you live in? Slanje is Croatian/Serbian word, right?
0
 
BuggyCoderCommented:
Try This one out:-
i have replaced ','(comma) with ';' (semi-colon)

ArrayList ar = new ArrayList();
ar.Add("abc.com");
ar.Add("hello.com");
string[] arrStr=(string[])ar.ToArray(typeof(string));
string addList = String.Join(";", arrStr);

Call doc.ReplaceItemValue("SendTo", addList)

This is in C#, kindly get the idea!!!

0
 
kahvedzicAuthor Commented:
I live in B&H, yes its C/S word you were right. I will try this (and @BuggyCoder solution).
0
 
mbonaciCommented:
There's really no need to use ArrayList if you need to create array with fixed number of Strings - meaning names/addresses (at least in Java, that is).
That's just an overhead.

Lists are good when you:
 - don't know the size of the collection
 - need to do plenty of inserts, especially inserts at different positions
0
 
kahvedzicAuthor Commented:
Thanks mbonaci its working like a charm when I use Textbox.Text in string array. Just fine thanks once more neighbour ;)

Cheers.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 5
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now