Results 1 to 8 of 8
  1. #1
    corkman is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Program.launch() - what if a default email client is not set?

    Hi there,

    I am using Program.launch(mailto) to email a pdf attachment.

    I want to send a message to client, if default email client is not set.
    How can I throw a message, if default email client is not found? I prefer swt than awt approach.

    In awt, I can see Desktop desktop.mail(mailto) throws an IOException, when default email client is not set. But Program.launch() does not.

    Any help is appreciated.

    cheers,

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: Program.launch() - what if a default email client is not set?

    So where did you get this Program class of yours, since it is apparently not a standard JDK class? And why are you not using the Desktop class if that does what you want?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    corkman is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Re: Program.launch() - what if a default email client is not set?

    Quote Originally Posted by gimbal2 View Post
    So where did you get this Program class of yours, since it is apparently not a standard JDK class? And why are you not using the Desktop class if that does what you want?
    Thanks for your reply. I am using org.eclipse.swt.program.Program. My application is using eclipse and SWT when necessary so I prefer using SWT.
    sample code is:

    public void openMailWindows(String to, String subject,String body, List<File> attachments)
    {
    StringBuilder strBuilder = new StringBuilder();
    strBuilder.append("mailto:");
    strBuilder.append(enc(to));
    strBuilder.append("?subject=");
    strBuilder.append( enc(subject));
    strBuilder.append("&body=");
    strBuilder.append(enc(body));

    String mailto = strBuilder.toString();

    for (File f : attachments)
    {
    mailto += "&attach=" + f.getAbsolutePath();
    }

    Program.launch(mailto);
    }

    I am just wondering, if there is a way to handle my issue in SWT ?

    cheers,

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: Program.launch() - what if a default email client is not set?

    Sorry, I missed that this was posted in 'eclipse'. But the next time you should mention which third party API you're using. Also notice that there actually is an SWT specific forum:

    SWT / JFace

    I'm sure a friendly moderator will move this thread eventually.

    In any case, I don't know because I don't use SWT. But I do know how to read documentation, so I google "java swt javadoc" to find the API documentation, and within a minute locate the documentation for the Program class.

    http://help.eclipse.org/indigo/topic...m/Program.html

    Checking the launch() method, I see it returns a boolean to indicate if the launch was successful or not. Simple no?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    corkman is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Re: Program.launch() - what if a default email client is not set?

    Thanks.
    Yes, I saw that. Not successful could be because of many reasons. I need the case, where only email client is not set.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: Program.launch() - what if a default email client is not set?

    Understandable, although no email client being set is the most likely reason for it failing so you COULD make that assumption.

    And another forum etiquette tip: if you create new threads, be sure to link to older ones so people can follow the link and see what has already been posted. That is especially true when you create threads on different forum sites.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default Re: Program.launch() - what if a default email client is not set?

    Quote Originally Posted by gimbal2 View Post
    I'm sure a friendly moderator will move this thread eventually.
    How about a grumpy one with a cough?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,703
    Rep Power
    5

    Default Re: Program.launch() - what if a default email client is not set?

    Quote Originally Posted by Tolls View Post
    How about a grumpy one with a cough?
    Don't lie to yourself, you're just lovely.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Error Using Email Client tutorial from Java-Tips
    By lasyn in forum AWT / Swing
    Replies: 6
    Last Post: 09-28-2011, 08:41 PM
  2. About the Email Client tutorial from Java-Tips
    By St Pierre in forum AWT / Swing
    Replies: 18
    Last Post: 03-16-2011, 08:57 AM
  3. email client
    By gvpproject in forum AWT / Swing
    Replies: 4
    Last Post: 03-01-2010, 12:33 PM
  4. Open source Email client (Desktop Based)
    By success21061985 in forum Advanced Java
    Replies: 1
    Last Post: 01-18-2009, 07:00 PM
  5. Access Email usind a java mail client Access Email usind a java mail client
    By consult4u in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-31-2007, 08:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •