Send email with native mail program

Hi!
I am writing a web application emails are auromatically prepared for the user to send. The catch is that I need to either send the mail using the clients native email application or find a way of adding the sent mail to the sent items folder of the native mail program. I have spent quite some time researching this. Am I trying to do the impossible?
Many thanks in advance

Hi!
http://java.sun.com/products/javamail/
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.net.ConnectException;
public class Email
String recipient;
String message;
public Email(String recipient,String message)
this.recipient = recipient;
this.message = message;
public void postMail( String recipients, String message ) throws MessagingException
System.out.println("Email IS called");
String subject = "Mail from ";
String from = "[email protected]";
boolean debug = false;
String smtpHost = "mail.XXXX.com";
String popHost = "mail. XXXX.com";
String username = " XXXX @ XXXX.com";
String password = " XXXX";
//Set the host smtp address
     Properties props = System.getProperties();
props.put("mail.smtp.host", "mail. XXXX.com");
System.out.println("Email IS called1");
     // create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// Pop Authenticate yourself
Store store = session.getStore("pop3");
     System.out.println("Email IS called2");
store.connect(popHost, username, password);
     System.out.println("Email IS called3");
// Define message
MimeMessage mmessage = new MimeMessage(session);
mmessage.setFrom(new InternetAddress(from));
mmessage.addRecipient(Message.RecipientType.TO,
new InternetAddress(recipients));
mmessage.setSubject(subject);
mmessage.setContent(message, "text/plain");
// Send message
Transport.send(mmessage);
     store.close();
//For EMail
Email emailser1;
email1 = "XXXX@ XXXX.net";
     emailser1 = new Email (email1,tomessage);
          try
               emailser1.postMail(email1,tomessage);
          catch(Exception e)
               System.out.println("Email sending error "+e);
     System.out.println("Email sending tomessage");
Hope this helps!

Similar Messages

  • Problem sending emails with Mac Mail 1.3.11

    Desperately in need of help. I'm able to receive but not send email using Mac Mail. I keep getting an error message:
    "This message could not be delivered and will remain in your Outbox until it can be delivered.
    The sender address [email protected] was rejected by the server"
    I have already tried the following at the advice of AppleCare reps:-
    Have verified & repaired disk utilities & keychains
    Have reinstalled the operating system
    Have trashed the mail.plist file
    Have trashed the outbox.mbox file
    Getting quite frustrated now because we have a mac bookpro with identical mail settings and it is able to send and receive mail without any problems.Could it be the version of Mail I'm running ?
    I initially thought that the problem related to having switched to a new ISP but the fact that one of the mac's has no problem has led me to be less convinced of that idea.
    Any suggestions gratefully accepted.
    Many thanks

    I am having the same problem exactly. I can read e-mail, but get the same error message trying to send it. I can't use .Mac anymore--have to use alternate e-mail for the last month--since some time in October 2006.
    I haven't changed anything on my G4, haven't upgraded anything, and the problem started about the time .Mac reported some customers were unable to use Mail for a couple of days in October.
    I see nobody answered your post. Did you ever get your mail to work? I have repaired permissions, but I don't think it has anything to do with that.
    Thanks,
    iMama
    G4 Quicksilver 867Mhz 60GB   Mac OS X (10.3.8)   Maxtor 120GB internal; LaCie 150GB external HD

  • How do I sync comcast email with the mail program on my iPhone and iMac

    I have two email accounts set up on my iPhone. One is my gmail account which I use for work. The other is the comcast email, my default home email address. The comcast account doesn't sync iPhone, web mail, or the mail program on my iMac at home. My gmail account does. For instance, I send an email from my phone it shows up in the sent box when I go to the mail web page on my work and home computer. With comcast, if I send an email from my phone it stays on my phone. I have to bcc or cc to myself if I want the sent message to show up on the home computer or on the mail web page.

    Unfortunately that is really the only work around since
    Comcast uses POP3 and not IMAP like Gmail or
    iCloud.
    I had received an email quite some time ago that they
    were beta testing IMAP with select customers but I doubt
    if it has gone much further than that.

  • Users Having Troubling Sending Email with Mac Mail Client with Godaddy

    Hello,
    I recently had issues' with my mail and my new Mac Pro and sending emails from www.godaddy.com. I tried 4 email clients and could retrieve my emails but the outgoing mail server keep rejecting my password. After I almost switch email companies I called one last person from godaddy. The support person James M suggested deleting the account in my email manager on godaddy system and re-created the account and everything works fine. Please note, to back up emails before doing this. I think something is corrupting something in the server that requires the deletion of the email account that is only effecting 10.64 users.
    Best of luck,
    M

    Have GoDaddy reset the SMTP relays to 0 (zero), then back up to 250 (or whatever your limit is). This reset the password authentication and emails were sent fine afterwards. Good luck.
    Marc

  • Trouble Reveiving (but not sending) email with Mac Mail

    I only intermittently can recieve yahoo emails on my new Air. Sending is no problem. Also recieve most, but not all, messages on my iPad. Sending also ok. But my iPhone sends and receives perfectly. Cants get help from apple, yahoo or time-Werner cable. ALL suggestions greatly appreciated. Very frustrated with my new Apple gear.

    Well, since your iPhone receives perfectly, use it as the model to set up your iPad and MacBook Air.
    On your iPhone, check Settings > Mail, Contacts, Calendars > (your Yahoo account).  Check the Incoming Mail Server settings, particularly the host name and server port (if you have that, it may be under "Advanced").
    Make sure they're set the same on your iPad.  On your Mac, in Mail, go to Mail > Preferences > Accounts and look under your Yahoo account.

  • Why does firefox close every time I try to send email with Hot mail and I have no other problems?

    It looks like other people are having the same problem with Hotmail from the posts in the Hot mail forum. They suggested I contact support for my browser. I thought Firefox was the problem, I uninstalled it and installed the newest version. CC cleaner is used every time my computer reboots and Firefox is set to remove history each time it restarts. I defrag and shred free space weekly. My computer has no other issues whether on line or off. The problem of Hot mail crashing my browser/s started over a week ago. I am able to access my account/read/ click on links/delete/clear spam folder . . . . but the instant I click on reply, new, compose, (?) any browser will crash within 20 seconds. There have been no recent changes to my computer BEFORE Hotmail began crashing my browser/s. I have had {removed email address} for many years and this is the first time I have seen this happen. I do not receive error messages, it simply closes my browser. Firefox is my primary default browser. As I said Firefox was re-installed AFTER this started happening. I have 3 gmail accounts , they all work fine. I have too many contacts in my Hotmail account to open a new account with another provider. This is my personal email not business. It look as if a lot of people are having this same issue with Firefox?!?

    Does it help if you disable the plugin-container process?
    See http://kb.mozillazine.org/Plugin-container_and_out-of-process_plugins

  • How do I use my iPhone's hot spot to send email with Mail ?

    Hi,
    My land line is dead ... so no phone nor internet at home.  But I can use my iPhone'hot spot to get on the web from my iMac.  Great ... it works !
    Oups !   I cannot send email from my computer using my iPhone's hot spot with Mail.
    How do I do that ?
    Regards.
    Robert Lespérance

    Hi Templeton Peck,
    Thanks for droping in my thread ...
    Doesn't the fact that I can surf the web with my iPhone's hot spot and that I cannot use Mail normally has I normally do give you a clue what the problem could be ?
    What other information can I give you other than normally I can surf and send email with my regular ISP.  Now that my ISP is dead I am using my iPhone's hotspot to surf the web awaiting that my ISP's connoection returns. Surfing is OK but I cannot send emails with through Mail.
    When I want to send an email from my computer, I get a message asking me to select the the SMTP server.  Then I select my usual ISP server, but the message comes back telling me it does not work.
    Is there any other configuration to do ?

  • Can't send emails with optonline...

    For some reason, I became unable to send emails with Mac Mail about 3 weeks ago. Did not change anything... For a while couldn't connect to the server with connection diagnostics, but now I can and it still won't send.
    Any ideas?

    anything? my wife has no problem on the same computer with her login, also with optonline. I am cursed...

  • How can I request a return receipt when sending email from Leopard Mail?

    Has anyone found a way to request return receipts when sending email with Leopard Mail?

    see this [link|http://discussions.apple.com/thread.jspa?messageID=7244096&#7244096].
    However,
    this is only possible if the email client of the e-mail receiver supports this feature and it is turned on. if it doesn't support it or it supports it but the feature is turned off there is absolutely nothing you can do.

  • I'm not able to send emails with mail.ru. Receiving and reading is not a problem. When I create a email with mail.ru its not possible to send it although its stored in my mail.ru account as "still to be send". What can it be??

    I'm not able to send emails with mail.ru. Receiving is not a problem. Creating a mail is also not a problem and the mail will be stored at mail.ru as still to be send, only problem is its not possible to send. I noticed the buttons for sending change colour when used but they don't perform. What it is?

    Don't know what changed, but all of a sudden able to send emails by mail.ru ...... sorry for bothering.

  • XI Mail Adapter: sending emails with attachment with help of java mapping

    Hi ,
    On trying out the scenerio mentioned in the blog, using the java mapping provided
    "XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    The scenerio works just fine.
    But the payload as the content of the attachment is not getting generated in proper XML format.
    I suppose it's because of the replace special characters code part..
    Can anyone help me state the modification required in the code.
    Thanks!
    Regards,
    Faria Mithani

    It might be a codepage issue. Is your original payload UTF-8?

  • Problem with Thunderbird email: When I send email using a mailing list, with my email included in the list, the message shows up in my Sent list and others rece

    Problem with Thunderbird email:
    When I send email using a mailing list, with my email included in the list, the message shows up in my Sent list and others receive it but it does not come to my email Inbox. The same problem occurs when I send the email to the mailing list addresses individually. When I send a simple test message to myself, I do receive it in my Inbox. Can you help me??
    Bob Greenman

    Are you using either cc or bcc? Is googlemail involved? Some email providers suppress cc's and bcc's to oneself since you will have a copy in your Sent folder.

  • Cannot send emails on Yahoo mail. It works okay with Safari. I set default to Yahoo but still cannot send

    Use MAC. Cannot send emails through Yahoo mail through Firefox but can send through Safari.
    Also issue with Facebook. Using Firefox cannot sign out of account. Can sign out when using Safari.

    Which security software (firewall, anti-virus) do you have?
    Boot the computer in Windows Safe Mode with network support (press F8 on the boot screen) as a test to see if that helps.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • TS3276 Mac Mail won't send emails with signatures

    My Mac Mail won't send emails with signatures. I get the "whoosh" sound and they show in sent mail, but the recipient doesn't receive them until I take off the signature and resend the email. Without a signature, it is received. It never used to be a problem, but started this past month. Please advise!

    Did Earthlink have you try using their authenticated SMTP server?
    If not, try changing Earthlink's SMTP server settings to the following:
    SMTP Server: smtpauth.earthlink.net
    Server Port: 25 or 587. Assuming Earthlink is your ISP, 25 should work.
    Use Secure Sockets Layer (SSL): Off or not selected.
    Authentication Type: MD5 Challenge-Response. Not sure if this authentication type is available with 10.2 and if not, select Password.
    User Name: Your entire Earthlink email address.
    Password: The password for your Earthlink email account - the same password used to check the incoming mail server for new messages.

  • Program To Send Email with attachemnts in PDF / Excel with Subject

    Hi All,
    I have been given an Object to Develop a report to Send Email with attachemnts in PDF / Excel with Subject.
    Please provide the way to go about.
    Regards,
    Mohsin

    REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    Receivers
    receiver_list-recextnam = 'type your email address here'. "-->
    EMAIL ADDRESS
    RECEIVER_list-RECESC = 'E'. "<-
    RECEIVER_list-SNDART = 'INT'."<-
    RECEIVER_list-SNDPRI = '1'."<-
    APPEND receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    Mail body
    APPEND 'Message content' TO message_content.
    Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    object_hd_change = w_object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    TABLES
    objcont = message_content
    receivers = receiver_list
    packing_list = packing_list
    att_cont = compressed_attachment.
    Hope it helps,
    regards,
    kushagra

Maybe you are looking for

  • 10.6.8 update added a non functioning app...

    It seems the 10.6.8 update added Photo Booth to my applications folder. The icon has the "No" symbol on top of it, and clicking on it brings up the message: "You cant open the application Photo Booth because it may be damaged or incomplete." It seems

  • "Class not found oracle.mtgC:\oracle\ora81\omwb\bin"

    After installation of Oracle Migration Workbench, I tried to run it but I receive this message: "Class not found oracle.mtgC: \oracle\ora81\omwb\bin". What happens in this case??? Can someone help me? null

  • Do not see my ohotos from Iphotos in Imovies

    Hi, I do not see the latest photos stored in IPhotos from the window in Imovies. If I create an album, I see the album, but not the photos within the album. How should I proceed ? Nicolas

  • Oracle Web Services Manager Gateway

    I need help! :( When I try to add a service to a gateway (import from uddi) I receive this error: * Failed to assign default policy * null where is the problem??? :°

  • Slow localhost connections

    I updated a couple packages the other day on two different systems, and now my locahost connections are slow.  At first I thought it was some /etc/hosts problems on the one machine because I had added some things to it.  But then I discovered the oth