dcsimg
How can I get the SMTP server value that I have on the computer that I use without typing it manually?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, December 14, 2003 04:40 PM

When I want to use the method SendMail(), I need to have the mySMTP-string to put in it. But HOW do I get it without having to write it manually before I do the method call. I want the application to check the SMTP server for me. I have tried many different ways, but I always get a "Null" value Here, why do smtp get a nullvalue? String smtp = toString().valueOf(properties.getProperty ("mail.smtp.host")); public void SendMail(String recipients, String subject, String message, String from,String mySMTP) throws MessagingException Properties props = new Properties(); //It's this mySMTP I want to get without typing it manually props.put("ma   More>>

When I want to use the method SendMail(), I need to have the mySMTP-string to put in it. But HOW do I get it without having to write it manually before I do the method call. I want the application to check the SMTP server for me.



I have tried many different ways, but I always get a "Null" value



Here, why do smtp get a nullvalue?


String smtp = toString().valueOf(properties.getProperty
("mail.smtp.host"));



public void SendMail(String recipients, String subject, String message, String from,String mySMTP) throws MessagingException



Properties props = new Properties();



//It's this mySMTP I want to get without typing it manually


props.put("mail.smtp.host", mySMTP);



// create some properties and get the default Session


Session session = Session.getDefaultInstance(props, null);


.


.


I would be so greatful I you could answere this question / Carl

   <<Less

Re: How can I get the SMTP server value that I have on the computer that I use without typing it manually?

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, December 15, 2003 11:31 AM

Are you saying that you set your property "mail.smtp.host" correctly, somewhere in some properties (? a ResourceBundle on your CLASSPATH? an init param for a web app? a runtime command-line arg?), but then it comes out null when you go to get it?


Or are you asking how to set this property somewhere, e.g. in one of those places, so your application can access it at runtime?


Or are you asking something else? Are you thinking that there might be some other application on the local host, with its own properties configured, including a "mail.smtp.host" or equivalent, which you could somehow read from your own application?


I think it would be a lot easier to just explicitly set your own, than to play around with searching for possibly installed local mail applications and configurations which are out of your control? ("you" being your current application plus whatever installation/configuration environment you have with it)

About | Sitemap | Contact