Solved

Send LN mail to multiple address from asp.net

Posted on 2010-11-26
13
866 Views
Last Modified: 2013-12-18
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
Comment
Question by:kahvedzic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
13 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 34217021
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
 
LVL 1

Author Comment

by:kahvedzic
ID: 34217048
OK but how to separate addresses in array only with "," or ", " or ";" (without "" of course)?
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34217511
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 20

Expert Comment

by:BuggyCoder
ID: 34219619
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
 
LVL 1

Author Comment

by:kahvedzic
ID: 34224898
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
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 34226363
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
 
LVL 22

Expert Comment

by:mbonaci
ID: 34228475
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
 
LVL 1

Author Comment

by:kahvedzic
ID: 34229959
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
 
LVL 22

Accepted Solution

by:
mbonaci earned 500 total points
ID: 34230088
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
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 34230105
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
 
LVL 1

Author Comment

by:kahvedzic
ID: 34230157
I live in B&H, yes its C/S word you were right. I will try this (and @BuggyCoder solution).
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34230325
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
 
LVL 1

Author Comment

by:kahvedzic
ID: 34230568
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question