Email someone from an application

Does anyone know what to send emails from a java application?
I want to select the infromation to go into the email from a database, then email this information to someone...
I need this to be done automatically...
For example, when someone updates their user profile, i want to send an email automatically to their account with their new details.....
I just dont know where to start....
all suggestions will be welcomed...

Use this class:
public class SendMail {
   * Creates a SendMail instance. Same as:
   * <code>SenMail(from, to, null, subject, message,
   * "Amic-Mailer", mailhost, user, password, new Date())</code>
  public SendMail(String from,
                  String to,
                  String subject,
                  String message,
                  String mailhost,
                  String user,
                  String password) {
    this(from, to, null, subject, message,
          "Amic-Mailer", mailhost, user, password, new Date());
   * Creates a SendMail instance.
   * @param from From address. Can be a null value.
   * @param to To addresses, coma or space separated.
   * @param cc CC addresses, coma or space separated.
   * @param subject Subject of the message.
   * @param message The body of the message.
   * @param mailer Set as the X-Mailer header.
   * @param mailhost The SMTP server.
   * @param user User name. If null then no authentication is used.
   * @param password Password.
   * @param date Date set to the sent date field.
  public SendMail(String from,
                  String to,
                  String cc,
                  String subject,
                  String message,
                  String mailer,
                  String mailhost,
                  String user,
                  String password,
                  Date date) {
    this.from = from;
    this.to = to;
    this.cc = cc;
    this.subject = subject;
    this.message = message;
    this.mailer = mailer;
    this.mailhost = mailhost;
    this.user = user;
    this.password = password;
    this.date = date;
   * Performs the action of sending.
   * @throws MessagingException As described in JavaMail API.
  public void send()  throws MessagingException {
    Properties props = System.getProperties();
    if(mailhost != null)
        props.put("mail.smtp.host", mailhost);
    if(user != null)
      props.put("mail.smtp.auth", "true");
    else
      props.put("mail.smtp.auth", "false");
    Session session = Session.getDefaultInstance(props, null);
    Message msg = new MimeMessage(session);
    if (from != null)
      msg.setFrom(new InternetAddress(from));
    else
      msg.setFrom();
    msg.setRecipients(
      Message.RecipientType.TO,
      InternetAddress.parse(to, false)
    if (cc != null)
      msg.setRecipients(
        Message.RecipientType.CC,
        InternetAddress.parse(cc, false)
    msg.setSubject(subject);
    msg.setText(message);
    msg.setHeader("X-Mailer", mailer);
    msg.setSentDate(date);
    if(user != null) {
      msg.saveChanges();
      Transport transport = session.getTransport("smtp");
      transport.connect(mailhost, user, password);
      transport.sendMessage(msg, msg.getAllRecipients());
      transport.close();
    else
      Transport.send(msg);
  private String from, to, cc, subject, message,
          mailer, mailhost, user, password;
  private Date date;
}You will need this jar files in your classpath:
activation.jar (from JavaBeans Activation Framework JAF)
mail.jar (from JavaMail)

Similar Messages

  • Sending email alert from SAP Application System

    Hi,
       we have one scenario like we need to send one email alert from application system, if ther is some error in  proxy or any error is ther in SXI_MONITOR of application sytem. Is ther any way to achieve this.
    Regards
    Pradeep P N

    >
    Pradeep P N wrote:
    > Hi,
    >
    >    we have one scenario like we need to send one email alert from application system, if ther is some error in  proxy or any error is ther in SXI_MONITOR of application sytem. Is ther any way to achieve this.
    >
    >
    >
    > Regards
    > Pradeep P N
    for sending mails from application system you can use various FMs -
    http://sapr3.tripod.com/abap011.htm
    http://www.sap-basis-abap.com/abap021.htm
    for XI related you can always utilize alerts

  • How can i email someone from apple?

    I think I need help from someone at apple since I can't find any answers through these forums. I can't call because I'm outside the US and I don't have a phone, and I'm not good enough at Japanese to read the Japan support site it sent me to. Is there an email address I can send this to? Sorry to ask this...I've been looking on the site but I can't find one.

    FOR ASSISTANCE WITH ORDERS - iTUNES STORE CUSTOMER SERVICE
    For assistance with billing questions or other order inquiries, please refer to our online support page by clicking here: http://www.apple.com/support/itunes/store/. If you cannot find the answers you are seeking in our robust knowledge base, you can contact us by visiting the following URL http://www.apple.com/support/itunes/store/, clicking on the appropriate Customer Service topic, then using the contact button or email form at the bottom of the page. Responses to emails will be provided as soon as possible.
    Phone: 800-275-2273 How to reach a live person: Press 0 four times
    Hours of Operation: Mon-Fri: 9am-5pm ET
    Email: [email protected]
    How to report an issue with Your iTunes Store purchase
    http://support.apple.com/kb/HT1933
    How to Get a Refund from the App Store
    http://gizmodo.com/5886683/how-to-get-a-refund-from-the-app-store
     Cheers, Tom

  • List Alert emails sent from one Application and not another?

    I have a farm with two Applications. For some reason, list alerts are being sent and delivered from Application A but not Application B.
    Troubleshooting recommendations?
    Thanks,
    Scott

    Hello,
    Check the property of alert for that web application using STSADM. If it is not enable then enable it.
    Stsadm.exe -o getproperty -url http://web-App-URL -pn alerts-enabled
    http://social.technet.microsoft.com/wiki/contents/articles/13771.troubleshooting-steps-for-sharepoint-alert-email-does-not-go-out.aspx
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Sending email via android email client from Air application

    Hello!
    I'm creating an Air application for Android and was wondering if it's possible to send an email via the android/gmail client within the application.
    Thank you for any help or direction in advance
    sjhitta

    Hi Jari,
    Thanks to reply me.
    There is an workspace details where user solve that problem but now i have troed to access that workspace but its not working .i have cofusion how can i do this where i put
    apex_mail.send(
    p_to => v_recipient_list
    , p_from => v_from_list
    , p_subj => 'Hello world'
    , p_body => v_body
    , p_replyto => null);
    this package
    and how to and where set SMTP of Gmail and i don't know about gmail SMTP Server Specification
    i ahve jus create a form with
    P1_TO Text Field
    P1_SUBJECT Text Field
    P1_FILE_BRE File Browse...
    P1_COMMENT Textarea
    Please guid me...how can i do that step by step
    Thanks

  • I need to email someone and Mail keeps opening up.

    I know that Mail no longer works and I get my .me email in iCloud but everytime I need to email someone from on online applcation, Mail opens up and I'm stumped!  How do I get my computer to recognize my email in the cloud rather than in Mail?

    Thanks,  I'm not really sure how I would do that.  i guess I need to make a trip to the Apple Store!  I was able to fix the isssue by just deleting and adding the other email account.  I think my other problem is with the third party's "send mail" feature. 
    Thanks for the help!

  • When I send a text from my iPad, it shows that it comes from my email address.  If I then text that same someone from my iPhone it still shows as if its coming from my iPad.  How do I stop this?

    When I send a text from my iPad, it shows that it comes from my email address.  If I then text that same someone from my iPhone it still shows as if its coming from my iPad.  How do I stop this?

    On your iPhone, go to Settings -> Messages -> Receive At -> Caller ID and make sure the phone number is selected - this will cause new messages sent from your iPhone to appear to come from your iPhone phone number.
    (I actually prefer to have my email selected, so that when I message someone from my iPhone and they reply, it goes to both my iPhone and iPad)
    Also, when you send a message from your iPhone, make sure you're not replying within an existing conversation (that was created on your iPad and linked to your email). Just start a new conversation (even if it's to the same person) by going to the Messages app, going back to "Messages" (top left corner) if you're already looking at a conversation, and then clicking the Compose icon in the top right.

  • I need to block someone from emailing me, its is also important that they receive an undelivered message when they attempt to email me.  Can this be done?

    I need to block someone from emailing me, it is important that they receive an undelivered message when they attempt to email me.  Can this be done? I do not mind deleting the whole account and starting again, but i have not found a way as of yet.

    You can go to the Mail page at http://icloud.com , click on the cogwheel icon at top right, choose 'Rules' and set up a rule that moves all messages from this person to the Trash. However there's no way of producing an 'undelivered' message.
    As to deleting the account, this isn't possible; you can abandon using it and start another. If you do this, messages to it will pile up until the storage limit is filled, at which point they will be bounced with an 'Account over limit' message. Alternatively you could set up a 'Vacation message' in the Preferences which would inform anyone sending to that address that it was no longer in use.

  • Can I send email address, message, etc. to TB from another application via DLL

    I have an application written in Omnis Studio version 4.X. It has the ability to act as a email client but only supports simple password authentication. I can get around this on the Mac by using AppleScript to send the contents of the email, to & from addresses, et. from my application to Mail. mail then acts as the mail client and processes the emails.
    I'm looking for a similar solution for my Windows users. Can TB accept a DLL message from another application as a way to pass an email from Omnis to TB?
    Thanks,
    Mike K

    No Mike, whilst it is probably possible considerable development effort would be required.
    Have you looked at the[http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29 command line switches]? perhaps they will do the job for you, but you still need to press the Send button to actually send the message.

  • What is wrong to cause someone replying to an email sent from my iPhone to always bounce back to them?

    What is wrong to cause someone replying to an email sent from my iPhone to always bounce back to them?

    It isn't for advertising. It is to let recipients know the message was sent from your iPhone in the event there are mispelled words, ect. You can add whatever you want such as sent from my mobile device.
    Settings > Mail, Contacts, Calendars > Signature. Select Clear and don't enter anything, or enter whatever you want.

  • How to setup adobe to send emails from the application?

    How to setup adobe to send emails from the application?

    Click Edit>Preferences and select the Email Account Preferences
    Click Add Account and select “Add other…” or if you use Gmail or Yahoo mail, select the appropriate choice for it.
    Enter your Email Account info and then click “Advanced Settings” and configure your incoming and outgoing mail settings per your email account in Outlook, Thunderbird or mail service.
    Click OK, and click Add. The new Email Account will now appear in your listed accounts.
    Click the new account and click “Make Default”
    The checkmark will indicate the new account is set as the default Email Account for Reader.

  • HT2500 whenever I open the mail application a flurry of past emails appears from nowhere. How do I stop this happening ?

    whenever I open the mail application a flurry of past emails appears from nowhere. How do I stop this happening ?

    1. If by flurry of emails you mean they all appear opened as if clicked on.
    2. Or do you mean your inbox fills up with a whole lot of 'new' unread emails downloaded from the server, so that if you delete them they return next time you open Mail.
    If it is 1. Press (three keys) Option + Command + W
    This will close all mail windows including the inbox.
    Then press (two keys) Command + 1
    to return the inbox.
    That should stop any flurry next time you open Mail
    If 2., Open Mail Preferences > Accounts (select the account in question if there is more than one), click on Advanced, and where it says remove copy from server after retrieving message, select that choice and click Remove now.

  • My emails come from computer to iPhone and iPad, but the emails sent from them do not sync to the computer. Can someone help me solve this? I have a 3Gs

    My emails come from computer to my iPhone 3GS and my iPad, but emails sent from those devices do not show up on my computer. Any ideas how to fix?

    Hi Phyllis715,
    If you are having issues sending emails from your iOS devices, you may find the following article helpful:
    iOS: Unable to send or receive email
    http://support.apple.com/kb/ts3899
    Cheers,
    - Brenden

  • I received 2 emails supposingly from Apple requesting that I update my profile.  Could someone confirm this is a scam?  Thanks.

    I received 2 emails supposingly from Apple asking me to update my profile because my account is blocked.
    Evidently, this is a scam.  Did others receive the same request?

    It's absoutely a scam, one which has been reported here a number of times. Do not respond to the email in anyway, just delete it.
    For more information on how to detect phishing messages purporting to be from Apple, see:
    http://support.apple.com/kb/HT4933
    Regards.

  • How to  delete email attachments from server

    Hi,
    I created an a CF template for sending e-mail which includes
    attachments. It has been tested on my dev box and is functioning
    fine as the attachment upload to a designated directory on the
    server. I would like the attachments to be purged once the e-mail
    has been forwarded to the recipent.
    In Macromedia's ColdFuision 7MX web application construction
    book page 913 "Interacting with Email" there is a CFC that will
    delete the file when the user ends their session.
    I am not sure how to write this to fit the code I am using.
    Here is the eMail form
    <!--- Mail_Form.cfm--->
    <html>
    <head>
    <title>Please enter your message</title>
    </head>
    <body>
    <form action="Send_Email.cfm" method="post"
    enctype="multipart/form-data">
    <table width="500" border="0" align="center">
    <tr>
    <td width = "500" colspan="2">Please enter your e-mail
    message:</td>
    </tr>
    <tr>
    <td width="250">To:</td>
    <td width="250"><input type="text" name="to_addr"
    value=""></td>
    </tr>
    <tr>
    <td>Subject:</td>
    <td><input type="text" name="subject"
    value=""></td>
    </tr>
    <tr>
    <td>Message:</td>
    <td><input textarea name="message" rows="5"
    cols="35"></textarea></td>
    </tr>
    <tr>
    <td width="250">Attachment #1:</td>
    <td width="250"><input type="file"
    name="attachment_1" value=""></td>
    </tr>
    <tr>
    <td width="250">Attachment #2:</td>
    <td width="250"><input type="file"
    name="attachment_2" value=""></td>
    </tr>
    <tr>
    <td width="250">Attachment #3:</td>
    <td width="250"><input type="file"
    name="attachment_3" value=""></td>
    </tr>
    <tr>
    <td width="250"> </td>
    <td width="250"><input type="submit"
    name="Send_Email" value="SendEmail"></td>
    </tr>
    </table>
    </form>
    Here is the form to send the attachment.
    <!--- Send_Email.cfm --->
    <!--- First make sure that the user uploaded attachments
    --->
    <cfif FORM.attachment_1 neq "">
    <!--- first actually upload the file --->
    <cffile action="upload"
    destination="D:\uploadsTEST\"
    filefield="attachment_1"
    nameconflict="makeunique">
    <!--- now create a temporary holder for the attachment
    later on --->
    <cfset attachment_local_file_1 =
    "d:\uploadsTEST\#file.serverfile#">
    </cfif>
    <!---Now repeat the process for the second and third
    attachment:--->
    <cfif FORM.attachment_2 neq "">
    <!--- first actually upload the file --->
    <cffile action="upload"
    destination="D:\uploadsTEST\"
    filefield="attachment_2"
    nameconflict="makeunique">
    <!--- now create a temporary holder for the attachment
    later on --->
    <cfset attachment_local_file_2 =
    "d\uploadsTEST\#file.serverfile#">
    </cfif>
    <cfif FORM.attachment_3 neq "">
    <!--- forst actually upload the file --->
    <cffile action="upload"
    destination="D:\uploadsTEST\"
    filefield="attachment_3"
    nameconflict="makeunique">
    <!--- now create a temporary holder for the attachment
    late on --->
    <cfset attachment_local_file_3 =
    "d:\uploadsTEST\#file.serverfile#">
    </cfif>
    <!---OK, you have now uploaded the file the server, now
    let's send
    out the email with the attachments:--->
    <cfmail FROM="[email protected]" to="#form.to_addr#"
    subject="#subject#"
    server="an001so-dby1c.pbi.global.pvt" port="25">
    #message#
    <cfsilent>
    <!--- <cfsilent> tag used to kill the white space
    in this area
    so your email is not cluttered with white space.--->
    <cfif FORM.attachment_1 neq "">
    <cfmailparam file="#attachment_local_file_1#">
    </cfif>
    <cfif FORM.attachment_2 neq "">
    <cfmailparam file="#attachment_local_file_2#">
    </cfif>
    <cfif FORM.attachment_3 neq "">
    <cfmailparam file="#attachment_local_file_3#">
    </cfif>
    </cfsilent>
    </cfmail>
    Here is the session application code to delete the file upon
    uploading
    <!---
    Filename: Application.cfc
    Executes for every page request
    --->
    <cfcomponent output="false">
    <!--- Name the application. --->
    <cfset this.name="attachmentPurge">
    <!--- Turn on session management. --->
    <cfset this.sessionManagement=true>
    <cfset this.clientMangment=true>
    <cffunction name="onSessionEnd" output="false"
    returnType="void">
    <!--- Look for attachments to delete --->
    <cfset var attachDir = expandPath("Attach")>
    <cfset var getFiles = "">
    <cfset var thisFile = "">
    <!--- Get a list of all files in the directory --->
    <cfdirectory directory="#attachDir#" name="getFiles">
    <!--- For each file in the directory --->
    <cfloop query="getFiles">
    <!--- If it's a file (rather than a directory) --->
    <cfif getFiles.type neq "Dir">
    <!--- Get full filename of this file --->
    <cfset thisFile =
    expandPath("Attach\#getFiles.Name#")>
    </cfif>
    </cfloop>
    </cffunction>
    </cfcomponent>
    The tutorial only explains how to delete the attachment when
    the recipient checks there mail
    in the POP server.
    Assuming that the sender is in a session would the code be
    written to delete the attached file from the directory on
    the server one the e-mail is sent.
    Can someone explain how to automatically delete email
    attachments from a designated directory or provide me with the code
    that would handle this after an email is sent with attachment.
    Thanks,
    Tony

    I don't know why your dos code didn't run. It could be
    addressing. My limited experience with cfdirectory/cffile/cfexecute
    is to type out the complete path at least once.
    Good books?
    Hard to say, depends on what else you are new at. If you are
    new to html, then htmlgoodies.com has good tutorials. So does
    webmonkey.com. If you have trouble with sql, I have heard good
    things about the SAMS book, Teach Yourself SQL in 10 Minutes by Ben
    Forta. I learned javascript by buying the book Teach Yourself
    Javascript in 24 Hours. The O'Reilly books are also good. I learned
    awk with one of those books.
    Glad you liked the fish pics. The camera is specified on most
    of the pages. If it says Reefmaster, I used an external strobe. If
    it says Sony I either used the camera flash only or natural light.
    By the way, that is not a Cold Fusion site. It's strictly html and
    javascript.

Maybe you are looking for