How to send email with an attachment in Groovy?

I have a user that is running remotely a groovy script to extract data from the Foglight Server.   When it executes this script, it has the ability to create a data file on the Foglight Server.  I would like to add a feature where this data file is sent to him and others.

So far, I have this:

email = new com.quest.nitro.service.sl.interfaces.email.EmailRequest ();

email.setRecipients (containers);

email.setSubject (subject);

email.setBody (body);

Server.get("EmailService").sendmail (email);

I looked at the documentation of the API and see setAttachment() method, but I don't know how to use it.  Could you please show a sample of how to send an email with an attachment (data file is a pure text file) using Groovy?

Thank you.

Hi Fred -.

Here's an example code that I have work. It should be suitable for files that are not too large:

/***************************

request.setBody ("Message body");

request.setSubject ("subject line");

request.setRecipients ("[email protected]");

text file you want to send as an attachment

FileInputStream fis = new FileInputStream("C:/textfile.txt");

buffer of bytes to hold the attachment - to ensure that its larger than the size of the file

Byte [] b = new ubyte [30000];

read the bytes of the fileinputstream, stuff on the accessory to set the mime type and give

Enter a file name for the e-mail client to use

FIS. Read (b);

request.setAttachment (b);

request.setAttachmentMimeType("text/plain");

request.setFileName ("emailAttachmentFile.txt");

ready to go!

emailService.sendMail (request);

********************************/

I hope this helps.

Robert

Tags: Dell Tech

Similar Questions

  • How to send email with an attachment when logged with Log me in?

    I need to access my home computer to get a file that I need.
    Im trying to use logmein in a public library that is used to allow me to connect... it's a firewall issue... so I used my iphone (3g) to connect to my home computer. How can I fix a file to an e-mail from my computer at home (gmail) to send to myself the library using logmein? Help

    Hello

    Please check with the support of LogMeIn.

    LogMeIn
    https://secure.LogMeIn.com/

    LogMeIn user support
    http://help.LogMeIn.com/SelfServiceLandingPage

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • Unable to send email with an attachment jpg

    Beat to death the MSNewsgroups without solution.  I have 2 comps which can send an email with an attachment jpg.  Attch no message is sent.  Message appears in the box shipping, then sent.

    Changed identity and a few other things - no joy.  Any thoughts would be appreciated.  WinXP SP3, OE6 connect via ISP

    Dave

    It looks like your ISP.  I would check with them on this subject as well.
     
    If its in sent items, then something downstream from your computer is to eat.
     
    Steve
     
    "Sabre Dave" wrote in message News: e4bdeaf2-6bac-4b7b-8e04-a30573e2e8e7...

    Send me - don't you

    Does not appear on the server webmail

    Changed identity - in fact twice, book imported & messages no problem - deleted all the rest

    Think I went through the past OE repair kit, but I'll check again and post back.

    D

  • How to send email with vista wwhen he does not support HTTP? Should I use POP3? If Yes, how can I get this info? ___Thanks in advance for your assistance__

    How to configure VISTA to send emails? I understand that I need to use POP3, but don't know hoe to get and apply the necessary information?  Please can someone help?

    Thanks in advance for all your help.

    shikosay
    E-mail address is removed from the privacy *.

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-Windows-Mail

    E-mail account:

     

    http://www.SimpleHelp.NET/2007/02/07/a-beginners-guide-to-setting-up-Windows-Mail/

    Link above has an easy to follow Guide to set up Windows Mail.

    Contact your ISP (Internet Service Provider).

    They offer your broad band/Dial-up connection.

    Ask them to:

    username
    password for your service account to wide band/Dial-Up with them

    Server of incoming POP3 mail
    outgoing mail SMTP server

    The above information is required to set up Windows Mail.

    ISPS are usually happy to help you set up your email account.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://support.Microsoft.com/kb/926374

    "You can not configure Windows Mail to use an e-mail account on the Web (HTTP) on a computer that is running Windows Vista"

    Windows Mail supports more HTTP servers that are used by Hotmail and other e-mail providers such as AOL mail, Google mail, Yahoo! mail Web.

    Read the info on the link above to Microsoft re HTTP and Hotmail.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Here is the workaround from MS:

    Use Windows Live Mail instead of Windows Mail

    Windows Live Mail is an e-mail program that you install on your computer. Windows Live Mail stores messages on your computer. This means that you can access, read, and compose e-mail messages even if you are not connected to the Internet.

    Windows Live Mail works with popular Web-based e-mail services such as Hotmail, AOL mail, Google mail, and Yahoo! mail. Windows Live Mail is designed to configure automatically many popular e-mail services.

    To install Windows Live Mail, see the Microsoft Web site at the following address.

    Mick Murphy - Microsoft partner

  • How to send emails with utl_mail not if there are no rows returned

    The following procedure works well as a daily planner job, except that I don't know how to prevent sending if there are 0 rows selected, an email which is most of the time. Sometimes we forget to take an oath before a new Member of the Board of Directors participate in its first meeting. It is designed to send an email before the meeting as a reminder. How to avoid sending empty emails every day?

    Thanks a lot for watching this.

    as
    vSender VARCHAR2 (30): = "[email protected]";
    vReceipt VARCHAR2 (30): = "[email protected]";
    vReceipt2 VARCHAR2 (30): = "[email protected]";
    vReceipt3 VARCHAR2 (30): = "[email protected]";
    vSubj VARCHAR2 (50): = 'OATH DO NOT TAKEN. "
    vMesg VARCHAR2 (4000);
    vMType VARCHAR2 (30): = text/plain"; charset = us-ascii';
    CURSOR c1 is m.first_name | Select' ' | m.last_name Member, bm.date_oath_taken, b.
    of minutes_members m, minutes_body_members bm, minutes_bodies b
    where m.id = bm.member_id
    and b.id = bm.body_id
    and bm.date_oath_taken is null
    and bm.body_id in (select body_id
    minutes_meetings where meeting_date between sysdate and sysdate + 3);
    BEGIN
    RUN IMMEDIATELY "ALTER SESSION SET SMTP_OUT_SERVER =" 10.0.0.10 "';"
    vMesg: = 'this is a list of not taken oaths | UTL_tcp. CRLF. UTL_tcp. CRLF;
    FOR c1_rec IN c1 LOOP
    vMesg: = vMesg | c1_rec. Member | » -'|| c1_rec. Description | UTL_tcp. CRLF;
    end loop;
    UTL_MAIL. Send (vSender, vReceipt, vReceipt2, vReceipt3, vSubj, vMesg, vMType, NULL);
    end;

    For example, you could test the variable 'vMesg '. If it is NULL then do not send the mail.

  • Tried to send email with an attachment, error message says too big and to resize - cannot find the email to return it - look in all folders? He did 2 times - HELP!

    Gmail is my email address, but I use it through Windows Live Mail.  I tried to send this record twice and I lost the email twice.  I sent before and it went ok, but I wrote an e-mail longer and I think that is why it is said that it is too long. After the error message the email disappears.  I looked through all my files and I can't find it anywhere.  Y at - it anywhere else I can watch or go to find it?  Thanks for your help!

    It has not been sent, should it be in the Outbox.
     
  • error code: 0x800CCC79 I can't send an email with an attachment to the email.

    Outlook express.  I can not send email with an attachment to this topic

    See if this helps: http://support.microsoft.com/kb/290808.  Make sure that "my outgoing server requires authentication" tab server from your account properties is checked. Brian Tillman [MVP-Outlook]
    --------------------------------
    https://MVP.support.Microsoft.com/profile/Brian.Tillman
    If a response may help, please vote it as useful. If a response to the problem, please mark it as an answer.

  • Since the upgrade to 31.1.0, I can't send an email with an attachment. I'm under OpenSuse 13.1 on KDE. How can I fix?

    If I try to send an email with an attachment or a picture inserted, it starts to send with a progress bar that will read a 80 to 95% completion and then stay there until it times out after a few minutes. I get this error: failed to send the message.
    The message cannot be sent because the connection to the server of SMTP outgoing.verizon.net expired. Try again or contact your network administrator.
    I use the same provider of e-mail for several years. This works for emails of simple texts without problem. If I try to transfer or to respond to an email, I get the same error.
    How can I fix?

    Thank you

    Robert

    OK, I thought about it. As I was going through the configuration editor, I saw the outgoing server settings. It made me wonder if something had changed. I went to my provider and reinforced through their list and found where mine differ. If the update for thunderbird changed something or verizon changed something.
    Thanks for the comments.

  • When I send an email with an attachment, the recipient cannot open it.

    I TRY to SEND YEAR EMAIL WITH AN ATTACHMENT OF THE WORD or PIECE WORK. THE PERSON RECEIVING THE MAIL CANNOT USE THE FORMAT AND THE APPLICATION TO BE CONVERTED TO PDF. HOW DO I DO THAT?

    Open the docunent in Word and save it as a PDF file.
     
    The Applications Microsoft Office forums
    http://answers.Microsoft.com/en-us/Office
  • How can I send emails with outlook express from firefox

    How can I send emails with outlook express from firefox

    See change the program used to open e-mail links for how to configure Firefox to use Outlook Express.

  • I can't send emails with the server that I use to receive. Can you tell me how to find my server from?

    Help send emails

    I can't send emails with the server that I use to receive. Can you tell me how to find my server going.

    Your provider of messaging service for this information.

  • Why, when I try to send or to send an email with an attachment I get the error message "Attachment Id has wrong format"... ?

    Why, when I try to send or to send an email with an attachment I get the error message "Attachment Id has wrong format"... ?

    Hi AndyHolman,

    ·         What email program are you using?

    ·         What is the attachment file extension?

    Try to remove your automatic signature in your mail and see if it solves the problem.

    Please provide us with some information so that we can help you solve the problem.

    You can also contact you Email Service Provider (ESP) for assistance on the issue.

  • How to send a large file attachment using iCloud mail

    I try to send an email with an attachment. The file size is 29.8 and message indicates the size of the file is greater than the limit of 28.5.  I can't find the mailbox. How can I find box mailbox?  Is there anything else I can do?

    Are you connect to your iCloud account, when you try to send the attachment of t? So little should be automatic:

    Send large attachments by using the mailbox

    You can use the mailbox to send files that exceed the maximum size allowed by your ISP email account . Mailbox post large attachments to iCloud, where they are encrypted and stored for 30 days.

    • If you have an iCloud account and you're connected to iCloud when you click on send, mail will automatically send the attachments using the mailbox. Mail attachments do not count against your storage iCloud.
    • If you have not an iCloud account, or if you are not connected, Mail asking you if you want to use the mailbox (always use send, select "no longer request for this account").

    If a recipient using Mail in OS X Yosemite or later, attachments are included with your message. For the other beneficiaries, your message includes links to download attachments and their expiry date.

    You can activate the mailbox or disable an account. Choose Mail > Preferences, click accounts, select the account, click Advanced, and then select or deselect the option "send large attachments with box.

  • Sending mail with an attachment of the IOM

    Hi Experts,

    We have an obligation to send an email with an attachment of the IOM. Unable to find any relevant document how this goal using the model Notification and NotificationService.

    Any help would be appreciated.

    Thanks in advance.

    This feature is not supported by the product. check the Doc ID 1444359.1

    You can trigger an SR to know about this.

  • Cannot send emails with Hotmail today

    Since yesterday, I can't send emails or make the answers with Hotmail. Before that, everything was fine.

    I have the same problem on several Mac and all at the same time. (Mac have different OS_.

    I can however, send emails with Safari without any problem, so there must be something with Firefox.

    Perhaps Microsoft changed something on the Outlook site (I guess when you connect you are redirected to the new site of Outlook). The site behaves as if sitting them buttons are "dead" so that the message is just there, or do you have an error message?

    Have you noticed all the other strange behaviors on your Mac Firefoxes, such as errors in secure certificate?

    Here are a few general suggestions:

    When you have a problem with a particular site, a good "first thing to try" is clear your Firefox cache and delete your cookies for the site.

    (1) delete the Cache of Firefox

    Sometimes, these temporary files mingle with files in a way that breaks a fresh site.

    This article has the steps: How to clear the cache of Firefox

    If you have a large hard drive, this may take a few minutes.

    (2) remove your cookies from live.com (save all pending work first of all if you can). While displaying a page on the site, try either:

    • Right click and select View Page Info > Security > "View Cookies".
    • (menu bar) Tools > Page Info > Security > 'view the Cookies '.
    • Click on the globe or padlock icon in the address bar > additional information > "View Cookies".

    In the dialog box that opens, live.com or mail.live.com should already be filled up. You can delete cookies from the site individually.

    Then try to reload the page and sign in again. Who help me?

    Could test you mode without failure of Firefox? It is a standard diagnostic tool to disable some advanced features of Firefox and extensions. More info: questions to troubleshoot Firefox in Safe Mode.

    Does not work if Firefox: Hold down the option key when starting Firefox.

    If Firefox is running: You can restart Firefox in Mode safe mode using either:

    • button "3-bar" menu > "?" button > restart with disabled modules
    • Help menu > restart with disabled modules

    and OK reboot.

    Two scenarios: A small dialog box should appear. Click on 'Start mode safe' (not update).

    Any improvement?

Maybe you are looking for

  • Re: Overheating and lag issues on the Satellite C660/C660D

    Hello community of Toshiba I am a new user of Toshiba, I have a new Toshiba laptop as a model of its Satellite C660 / C660D, I use my new laptop for 6 months and I have some kind of a lot of time on my laptop. Sometimes I keep it open for more than 1

  • Re: Wifi Internet is slow when the laptop unplugged, even after I changed power saving setting

    I have the exact same laptop HP 15-f010dx with exactly the same problem. I bought mine about 4 weeks ago. When its plugged I routinely get download 15, 5-14 Mbps. But when its unplugged I was getting only 1 to 2 Mbps download speed. I constantly rece

  • WPS54GU2 version number and power supply?

    I have three units of WPS54GU2.  We have a supply of 12 V DC, the other a 5 VDC power supply.  The other lost his DC power.  I don't know what supply goes with what unit. How can I find on what versions of WPS54GU2, I (version 1 or 2?) and the tensio

  • Detection of an outgoing MMS Message

    I know that an OutboundMessageListener class can be used to detect an outgoing sms message. Does anyone know what class to use to detect an outgoing MMS message?

  • Pinout table micro 60

    Can someone tell me the PIN on a Table 60 microphone? A technician in the removed Gayshop connector phoenix of the principal before them noting and now to find all the hard to find useful technical documents. There are four wires: a red, green, blue