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

Passing value into other class

hi experts,

I have a Servlet which calls sendMail.

Servlet:
...
Mail m = new Mail();
m.SendMail(fromAddress, toAddress)
...


Mail class:
..
public String sendMail(java.lang.String  from, java.lang.String to)
{
..
InternetAddress[] fromAddress = InternetAddress.parse(from);
...


THE ABOVE CODE WORKS FINE. Now what I'm trying is I need to get a String value as will in here.

Servlet:
...
Mail m = new Mail();
m.SendMail(fromAddress, toAddress, NewValue2Pass)

Now how to get this "NewValue2Pass" value into Mail Class ????


Thx,
PH
0
princehyderabad
Asked:
princehyderabad
  • 4
  • 3
2 Solutions
 
objectsCommented:
public String sendMail(java.lang.String  from, java.lang.String to, String newValue2Pass)
{
0
 
princehyderabadAuthor Commented:
Yeah that part I know how abt ....

String newValue2Pass = "";
InternetAddress[] fromAddress = InternetAddress.parse(from);
newValue2Pass = ????????//how to get values here ????
0
 
princehyderabadAuthor Commented:
do I need to parse that value and use or without parsing I can use.

eg:

String nvp = ????????//how to get values here ???? -- Parse and use
String text ="Message from"+nvp+"for .....";

or

String text ="Message from"+newValues2Pass+"for ....."; (directly use)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
objectsCommented:
what exactly is it u r trying to do?>
0
 
princehyderabadAuthor Commented:
This is what I'm trying to do:

....
public String sendMail(java.lang.String  from, java.lang.String to, java.lang.String fromName)
{      
          try {
                String textmessage = "You are receiving this notice because:"
                      +"<b>"+fromName+"</b> has been removed from your pending queue."
                ...
....

(Tying to display fromName in the text message..)

thx,
PH
0
 
objectsCommented:
that all looks fine, wher eis the problem?
0
 
princehyderabadAuthor Commented:
Thats all i wanted to know can I used "fromName"  in the Text String declaration or I have to parse "fromName" in some string and using this xy string in Text String to get fromName. I think you told its looks fine so that fine :o). Actualy I dont have SMTP to do R&D on it thats why making sure.

Also to add to this:
let say I have 2 mes:

String Message1= "..."
String Message2= "..."

I'm calling this mail class like this: rm.SendMail(to, from, fromName)

how can I use Message1 for to user = "xyz"
how can I use Message2 for to user = "abc"

This is the way I'm setting message:
message.setText(Message1);

Thx, PH

0
 
Mayank SAssociate Director - Product EngineeringCommented:
Pass it to your method:

public String sendMail ( String from, String to, String fromName, String message )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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