Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

changing a single recipient email engine to a multiple recipient email engine  RSS feed

 
chris calitri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this code which will send an email to one recipient. I was curious as to how I could modify it to send to multiple addresses?

Any advice would be greatly appreciated.

Thanks!


 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, chris.

When you post code, be sure to use code tags. I'll do it for you this time.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the code for sendFromGMail?
 
chris calitri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Knute,

Thank you i neglected to post the rest of the code. The full code is below. Thanks


 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like sendFromGMail has the code to handle multiple "to" addresses, so all you would have to do is add more recipients to the "to" array.
 
chris calitri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Knute,

Thank you for your help.

I should add it to:



Not


correct?

When I added to the above I got multiple errors.


Thanks,

Chris
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd either create RECIPIENT1, RECIPIENT2, etc., or create a String array constant RECIPIENTS.

Also note that to create a Java "constant", you need to make the field both static and final.
 
chris calitri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute,

Thank you for your help.

I tried to create a string array and got the following error:
"incompatible types: java.lang.String[] cannot be converted to java.lang.String

Any advice?

 
chris calitri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute,

Thank you for your help.

I was able to get it to work, if neglected to remove the brackets around RECIPIENTS.

Have a great weekend
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!