Please help me in sending mail to Microsoft Outlook

Hi!
I want to sned a mail from jsp or servlet to Microsoft outlook. Could anyone help me out in sending mail. It is a web-based project. I have to get the mail-id in a textfield and send it to that ID.
Regards,
Krishna.

Hi,
First of all; you don't send a mail to Microsoft Outlook. It's just one of many email clients. You send a mail to an email address using the most suitable protocol, for example SMTP.
That being said, Java actually supports the SMTP protocol, you don't even need to use an extra package such as JavaMail. Here's a small piece of code showing you how to do this.
public void sendMessage(String recipients,
                        String sender,
                        String subject,
                        String message,
                        String mailhost)
  throws IOException, MalformedURLException {
  // Specify the mailserver.
  System.getProperties().put("mail.host", mailhost);
  // Establish the connection to the mailserver.
  URL           u = new URL("mailto:" + recipients);
  URLConnection c = u.openConnection();
  c.setDoInput(false);    // No input from this URL.
  c.setDoOutput(true);    // Output to this URL.
  c.connect();
  // Print the message.
  PrintWriter out =  new PrintWriter(new OutputStreamWriter(c.getOutputStream()));
  out.print("From: ");     out.println(sender);
  out.print("To: ");       out.println(recipients);
  out.print("Subject: ");  out.println(subject);
  out.println();           // Blank line to end the list of headers.
  out.println(message);
  // Close the stream to terminate the message.
  out.close();
}Good luck,
  /Håkan

Similar Messages

  • Please help, how to send mails faster / send more mails per hour

    hello,
    in my application i am using mail sender class i have created to send mail to the users to participate in a survey. following is the code for it. i would like to know if there is anything wrong in it coz it takes to much time to send the mails it is taking 2 minustes to send 6 mails i.e 360 mails per hour only.
    following is how i instantiate the mail sender class and then generate a http link string dynamically as it is different for all the user.
    //////////class where mail sender is instantiated////////////////////
    try
    setConnection();
    st=con.createStatement();
    rs=st.executeQuery("select * from "+CNAME+"_campaign");                         
    String SurveyT = new String();
    while(rs.next())
         SurveyT = rs.getString(2);
    rs.close();
    rs=st.executeQuery("select * from "+CNAME+"_user");     
    ss = new MailSender();
    while(rs.next())
         String userid = rs.getString("userid");
         String password = rs.getString("password");
    StringBuffer message = new StringBuffer(BodyText.getText().trim());
    if(SurveyT.equals("invitational") || SurveyT.equals("single"))
                                            message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/servlet/login?username="+userid+"&passw="+password);
                                            ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
    else if(SurveyT.equals("general"))
    message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/Index.html");
    ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
    st.close();
    this.dispose();
    catch(SQLException sqlex)
    JOptionPane.showMessageDialog(null,sqlex.getMessage());
    //Mail Sender class/////////////////
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import javax.swing.*;
    public class MailSender
         String sentAddr,fromAddr,smtpServer,body,subject;
         public MailSender()
         //function send to send the mail
    public void send(String from,String to,String smtps,String subj,String messagetext)
              fromAddr=new String(from);
              sentAddr=new String(to);
              smtpServer=new String(smtps);
              body=new String(messagetext);
              subject=new String(subj);
              try
                   Properties props = System.getProperties();
                   props.put("mail.smtp.host",smtpServer);
         Session session = Session.getDefaultInstance(props,null);
    Message msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(fromAddr));
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(sentAddr,false));
         msg.setSubject(subject);
         msg.setText(body);
    msg.setHeader("Survey","MailCheck");
    msg.setSentDate(new Date());
         Transport.send(msg);
         catch(MessagingException mex)
              JOptionPane.showMessageDialog(null,mex.getMessage());
    }

    Lots of variables here....Also my maths says only 180 per hour.... i.e. three a minute.
    1) you are using a database to get info from. What is the average response time of the DB server? Looks like you are doing one SQL then reading the result table but does the initial SQL take a while?
    2) how much data are you passing on to the SMTP server and how fast/slow is the link to that SMTP server? Work out the absolute max amount of data you can transfer over the link then get your average message size and work out a VERY theoretical Max number of messages a minute. Note that real life might approach 80% of this taking TCP/IP and SMTP overheads into account.
    3) What sort of load is the SMTP server under? If it's busy you will be only getting a fraction of whatever bandwidth is available. Depending on its design it may be trying to deliver the first message you sent it while you are still pumping more messages down to it. SMTP servers may limit the number of connections per minute from another machine in order to defeat a denial of service attack. Your code makes a connection per email so this may have relevence here.
    4) Raw horsepower always helps. When I write stuff to do things like this there is no nice GUI screen etc. Just basic Java that if it has to will write a log if something goes wrong. Maybe just maybe a counter on STD out to show it is still actually doing something. Keep the number of classes used down to the bare minimum. In the old days we used to spend days paring code to the bone - a skill somewhat lost these days.
    Hope this gives you some help in finding the bottleneck.
    Cheers,
    SH

  • HT5312 I forget answer to my qustion with rescue email adrees please help me and send the answer to my main mail. Thank you very much

    I forget answer to my qustion with rescue email adrees please help me and send the answer to my main mail. Thank you very much

    We are fellow users here on these forums, you're not talking to iTunes Support.
    If you don't have access to your rescue email account, or you don't have one on your iTunes account, then you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down this page to add/change a rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • Is there anyway to send a mail from Microsoft Outlook to solution manager?

    Is there anyway to send a mail from Microsoft Outlook to solution manager.
    If anybody having notes or documents that will be very much helpful for me.
    Awaiting for your reply,
    With best Regards,
    Alexey

    Hi,
    It is just the inbound mail configuration as like the out bound config.
    Below are the required demo, blogs,helps
    [Demo on Mail from outlook|https://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/5087262b-59ef-2910-abb1-957000b7c3d4&overridelayout=true]
    [blog 1 for mail to SAP|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417800)ID1382272150DB00641126052855673650End?blog=/pub/wlg/795 ]
    [Artical inbound mail config|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/10dfad5a-5398-2b10-568b-d3d999d49b5c]
    Hope this helps
    Jansi

  • Failed to send E-mail via microsoft OutLook

    Hi All,
    Does anybody knows why this message appears when I tried to send an email via out look, using the button email on the B1 menu bar.  i have selected the user name and the email address correctly, i have ticked the option send emiail using microsoft outlook.  then the following error message appeared
    "BO2069: Failed to send e-mail via Microsoft Out look"
    the connection was established between outlook and b1 using the logon function in outlook integration addon.
    thanks
    SV Reddy

    Dear,
    If my last answer could not solve your issue, please refer to the informaiotn below:
    The reported issue occurs due to the fact that outlook can only send attachments from the Business One attachments folder.
    This issue has been fixed in 2005A SP01 PL41. Please refer to the note 1116389. As a solution we would suggest to upgrade to the latest patch level.
    Until you upgrade to latest patch of 2005A SP 01 you can use the following workaround:
    - Manually copy all attachments to the B1 attachment path before sending this mail. If you create a shortcut to your attachments folder in a convenient location (perhaps the desktop) this can be done very quickly. (Browse to your document, right click and select copy, press the Windows Key+D to go to your desktop, double
    click the shortcut, then paste into the attachments folder.)
    Alternatively, you could either:
    - Change the B1 attachment path to your attachment files path.
    or
    - Uncheck 'Send E-mail via MS Outlook', and send this message. Nowthese attachments will be copied to the Business One attachment path.
    Then send this message again, with 'Send E-mail via MS Outlook' checked.
    Further we would suggest to apply following steps:
    -upgrade your MS Office 2003 application to the current SP. (SP3)
    -verify that the sender's e-mail address defined for the sender in SAP Business One is valid.
    -Set up the correct smtp server in SBO Mailer / General Setting /Mail Settings (you should check with a "Test connection" button)
    Wish the information could solve your issue.
    Regards
    Apple

  • HT5312 Hello Please help me to send the link re-appoint security questions because of the loss of the answers thank you

    hello
    Please help me to send the link re-appoint security questions because of the loss of the answers
    I hope e-mail me as soon as
    Thank you

    You need to ask Apple to reset your security questions; ways of contacting them include phoning AppleCare and asking for the Account Security team, clicking here and picking a method for your country, and filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (105195)

  • How do I get rid of the Microsoft Setup Assistant loop? I migrated my software/documents from another laptop so don't have the disk to reinstall. Please help! Can't open any Microsoft Office software, like Word, and stuck in a loop?

    I migrated my software/documents from another laptop so don't have the disk to reinstall. Please help! Can't open any Microsoft Office software, like Word (for 2008), and stuck in a loop?
    Whenever I select Word Microsoft Setup Assistant appears, asks for feedback, then after selecting okay (both on saying yes or no to feedback) goes on to a registration page. When I click on this it says I've already registered so I just click okay, and then move on to a update page. After this, if I click on Word, the process repeats itself.
    As I said, I don't have the disk to reinstall, and can't find the Office Settings to delete as many pages have suggested I should try. Safe Boot restarting also hasn't worked... Really stuck and need Word very soon for work.
    If you can help, that would be great, and feel free to ask any questions about the situation as I'm not an expert here.
    Cheers,
    Jack

    First, export your contact from iCloud.com and save them on your computer in a safe spot some where (like you desktop).  Use this to help you do this: http://support.apple.com/kb/PH3606
    Next, on both of your devices, go to Settings > iCloud and turn on contacts and select Merge. Then turn off contacts and select 'Delete form my [device]' when prompted.
    Now go back to iCloud.com and select a contact (yes they will all be messed up again) and select Command+A on a Mac or Control+A on a PC to select all of the contacts.  Tap the delete key on your keyboard (or right click /control click a contact and select delete).
    You iPhone, iPad and iCloud.com should not be empty for contacts.
    Go back to Settings > iCloud on both devices and turn on contacts again (you should not see merge this time).
    Next, go back to iCloud.com and import your contacts (those exported .vcards).  You can either drag and drop them into the empty contacts list in your web browser, or you can use the gear icon to import.
    You cleaned up contacts should import correctly into iCloud.com and sync to both of your devices.
    Good luck.

  • I installed windows 7 on my macbook pro. all is working but lan adaptor and sound od laptop is not working. please help me or send the link where i can download the these drivers.

    I installed windows 7 on my macbook pro. all is working but lan adaptor and sound od laptop is not working. please help me or send the link where i can download the these drivers.I have lost my resource cd .

    If you are running Lion or Mountain Lion, the drivers are downloaded from within Bootcamp Assistant. If you are running Snow Leopard the drivers are on your Snow Leopard install disk.
    Read the Bootcamp Install Guide for your version of OSx. http://www.apple.com/support/bootcamp/
    Bootcamp questions should be asked in the Bootcamp forum where the Bootcamp gurus hang out https://discussions.apple.com/community/windows_software/boot_camp

  • I need to by apps but it keeps asking for my security questions ;/ but  forgot the answers to my security questions and the security/rescue email too (i dont have USA number to call please help me and send my rest to my email

    I need to by apps but it keeps asking for my security questions ;/ but  forgot the answers to my security questions and the security/rescue email too (i dont have USA number to call please help me and send my rest to my email

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (115668)

  • I can't send mails from my outlook 2010 but can receive, I can't send mails from my outlook 2010 but can receive

    I can't send mails from my outlook 2010 but can receive, please help.

    Thank you so much for your time and help Csound1 I really appreciate it.
    Mac mail works perfectly fine so I don't want to screw it up by altering anything there.
    However, I've checked to make sure I didn't miss anything on Outlook, but it still won't send messages. I don't know if I need to fill the "Unqualified domain" field?

  • Transfering mail from Microsoft Outlook to Microsoft Entourage

    Please tell me how to transfer the mails from Microsoft Outlook to Microsoft Entourage, can someone help? SOS! Thanks.
    Power Book G4   Mac OS X (10.4.4)  

    I used a program called O2M (Outlook2Mac) and it worked great.
    http://www.littlemachines.com/
    Good luck!
    Bronson

  • BO2069: failed to send email  med.Microsoft outlook

    HI ALL,
    We have an erro to send a document by sapb1 using Outlook integration BO2069: failed to send email  med.Microsoft outlook  
    If i open the outlook this erro occurs if i close the outllook the documents sends without problem. Is not funcional becase the user needs his outlook open.  Icant found information about it.
    Could you helple please?
    regards.
    NANCY HERNANDEZ.

    HI GORDON,
    I checkt your link and y I´ve aplied all suggestions but i have de same problem. the question is, Is normal that we have to close outlook to work ok with ms outlook integration in sap?. because this error doesnt appear when msoutllok  is close. but this is not functional.
    i hope your soon support.
    Regards
    NANCY HERNANDEZ.

  • Create a "Do Not Send" List for Microsoft Outlook for Mac 2011

    Hello,
    I've been having a problem creating a "do not send" list for Microsoft Outlook for Mac 2011.  Essentially, I am sending out bulk emails and when people want to unsubscribe I have no means to create a list so that no email is ever sent to them again.  Because of the number of emails going out, it would simply take to long to search each excel sheet of emails I have and purge the unsubscribers.
    Is there any way to create a list of emails that outlook will not send to, even if the names or in the excel sheet?
    If it helps, I am using a Microsoft Word document as the basis for my form letter emails, which then pulls the email contacts (hundreds of them) from an excel sheet, which then sends them to my outbox in Outlook.
    Thank you,
    Frank

    Microsoft Support – Office for Mac
    Microsoft Support – Office for Mac (2)

  • TS3276 Can't see the sent e-mails with Microsoft Outlook

    I can sent e-mails using Microsoft Outlook but i can't see the sent e-mails in the folder provided. I can only see them after someone has replied to it. What am i doing wrong?

    Sorry Thierry if I wasn't clear enough.
    I meant the Add-Ins tab in the Ribbon, not the Options:
    SAP does provide the functionality to hide the pane, on the bottom right you can see the top of the pane and there is an X. It can close it but the add-in stays on.
    Then in the Ribbon you can activate the "Add-Ins" tab and you will have the SAP Cloud for Customer menu command.
    This is what I meant in my initial reply by saying that I do that often. I hide the pane and reactivate it by simply clicking on that button highlighter in black above.
    At least in it's in Outlook 2010 but like you said in your initial post, maybe it is not available in 2013. Partho Guha will be able to confirm.
    JB.

  • Opening mail in Microsoft outlook

    Hi,
    I've noticed this question or ones similar to this have gone unanswered but I am going to try. Is there a way to open .mac mail in Microsoft Outlook in XP. I have a mac at home and I can use the mail app to look at my emails. At work I have to use a windows machine and I hate having to go on to the .mac website and login...etc..
    I have tried to set it up myself but I just do not know what server address to put into the setup.
    Even if this is impossible, could someone tell me so I don't keep trying forever.
    Thanks
    Jason

    I haven't accessed by .Mac account with Outlook but I do access my .Mac account with Outlook Express on my Windows PC at work.
    If you have not changed your .Mac account from a .Mac type account to a POP type account with the Mail.app on your Mac, you need to create the account as an IMAP type account in Outlook or Outlook Express. I also use Outlook for my business email account at work but I prefer using Outlook Express for my personal email account to keep things separate.
    Select IMAP as the account type.
    Incoming Mail Server: mail.mac.com
    Outgoing or SMTP Server: smtp.mac.com
    Account Name for the Incoming Mail Server: The portion of your .Mac email address in front of the @ sign only.
    Password: Your .Mac account password.
    For the Outgoing Mail Server, select "My server requires authentication" and also select "Use the same settings as my incoming mail server".
    Depending on your company restrictions, the only thing you may have trouble with is using the .Mac Outgoing or SMTP server at work.

Maybe you are looking for