• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • 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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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