How to send a mail as an attachment in a mail with AppleScript?

Hi,
I want to manage my spam using the advices found in support.apple website :
OS X Mail
Open the message and choose “Forward as Attachment” from the Message menu.
Forward the message to iCloud [email protected].
Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
I don't know how to make a message as an attachment...
set theAttachment to theMessage
make new attachment with properties {file name:theAttachment} at after last paragraph
Here is my whole script, if it runs, it could be useful :
tell application "Mail"
  -- envoi les messages sélectionnés en PJ à [email protected]
          set theMessages to the selection
          repeat with theMessage in theMessages
                    set theAttachment to theMessage
                    set newMessage to make new outgoing message at end of outgoing messages
                    tell newMessage
                              set subject to "Fwd: " & theMessage's subject
  make new to recipient with properties {address:"[email protected]"}
                              tell content of theMessage
  make new attachment with properties {file name:theAttachment} at after last paragraph
                              end tell
                    end tell
  send newMessage
          end repeat
  -- envoi les messages sélectionnés en PJ à abuse@<domaine du spammeur>
          set theMessages to the selection
          repeat with theMessage in theMessages
                    set theAttachment to theMessage
                    set newMessage to make new outgoing message at end of outgoing messages
                    tell newMessage
                              set subject to "Fwd: " & theMessage's subject
                              set theSpamAddress to theMessage's sender
                              set AppleScript's text item delimiters to {"@"}
                              set spamerDomainName to text item 2 of theSpamAddress
                              set theNewSpamAddress to "abuse@" & spamerDomainName
  make new to recipient with properties {address:theNewSpamAddress}
                              tell content of theMessage
  make new attachment with properties {file name:theAttachment} at after last paragraph
                              end tell
                    end tell
  send newMessage
          end repeat
end tell
Thank you!

Perfect!
You clearly give me the way. Actually I have used the AppleScript Language Guide from https://developer.apple.com to finalize my AppleScript.
You just need to select the spam message(s) in "Mail" application, then run the script.
As I mentionned previously, it just do this automatically :
OS X Mail
Open the message and choose “Forward as Attachment” from the Message menu.
Forward the message to iCloud [email protected].
Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
Here is the entire working script :
-- Ce script permet de lutter contre le spam.
-- Je me suis appuyé sur les conseils sur http://support.apple.com/kb/TS4019?viewlocale=fr_FR
tell application "Mail"
          set theMessages to the selection
          repeat with theMessage in theMessages
  -- enregistre le message dans un fichier pour le mettre en PJ ensuite
                    set msgContent to source of theMessage
                    set tmpFile to ((path to desktop) as rich text) & "ForwardedMessage"
                    set referenceNumber to open for access tmpFile with write permission
  write msgContent to referenceNumber
  close access referenceNumber
  -- envoi le message sélectionné en PJ à [email protected]
                    set newMessage to make new outgoing message at end of outgoing messages
                    tell newMessage
                              set subject to "Fwd: " & theMessage's subject
  make new to recipient with properties {address:"[email protected]"}
                              tell content of newMessage
  make new attachment with properties {file name:tmpFile} at after last paragraph
                              end tell
                    end tell
  send newMessage
  -- envoi le message sélectionné en PJ à abuse@<domaine du spammeur>
                    set newMessage to make new outgoing message at end of outgoing messages
                    tell newMessage
                              set subject to "Fwd: " & theMessage's subject
                              set theSpamAddress to theMessage's sender
                              set AppleScript's text item delimiters to {"@"}
                              set theSpamAddress to text item 2 of theSpamAddress
                              set AppleScript's text item delimiters to {">"}
                              set spamerDomainName to text item 1 of theSpamAddress
                              set theNewSpamAddress to "abuse@" & spamerDomainName
  make new to recipient with properties {address:theNewSpamAddress}
                              tell content of newMessage
  make new attachment with properties {file name:tmpFile} at after last paragraph
                              end tell
                    end tell
  send newMessage
          end repeat
end tell

Similar Messages

  • How  to send text file as an attachment to exteral mail

    hi ,
    Can any one tell me how to send an internal table as a textfile attachment  to the external mail.
    regards
    kishore

    hi,
    i am assuming txt fie attachment means you want notepad attachment
    recently i struggled on this and i achieved success by doing as below
    remember to keep packlist as RAW type like below:
    t_packing_list-doc_type = 'RAW'.
    do like this
    CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
        EXPORTING
          ip_solitab        = t_attachment[]
       IMPORTING
         EP_SOLIXTAB       = xtext[].
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data                    = w_doc_data
         PUT_IN_OUTBOX                    = 'X'
        COMMIT_WORK                      = 'X'
        tables
          packing_list                     = t_packing_list
        OBJECT_HEADER                    =
        CONTENTS_BIN                     = objbin
         CONTENTS_TXT                     = it_message
         CONTENTS_HEX                     = xtext
        OBJECT_PARA                      =
        OBJECT_PARB                      =
          receivers                        = t_receivers
       EXCEPTIONS
         TOO_MANY_RECEIVERS               = 1
         DOCUMENT_NOT_SENT                = 2
         DOCUMENT_TYPE_NOT_EXIST          = 3
         OPERATION_NO_AUTHORIZATION       = 4
         PARAMETER_ERROR                  = 5
         X_ERROR                          = 6
         ENQUEUE_ERROR                    = 7
         OTHERS                           = 8

  • How to send original filename as the attachment name through mail adapter?

    Hi,
    I have a File to Mail scenario where the file is picked up from a folder in R/3 system and is sent as an attachment through mail. The requirement is to send the file unconverted and with the same file name.
    When tried without creating any ESR objects, it was sending the file with the name Untitled.xml.
    Since the filename has to be picked dynamically, I am not able to configure it through module parameters also (where we can set it through Content_Disposition)
    I tried configuring it as mentioned in the following link: [http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=138084630]
    But still it is going as Untitled.xml with the whole mail package as the content of the attachment.
    Any pointers to solve this issue will be of great help.
    Thanks
    Justin

    there is no standard way so you will  have to write module beans.
    in other way:
    XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping - XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    Dynamic name in the mail attachment - pseudo "variable substitution" :
    XI: Dynamic name in the mail attachment - pseudo "variable substitution"
    Dynamic attachment name in receiver mail adapter

  • How to send a file as an attachment using mailx

    Hi
    Can any one tel me how to send a file as an attachment using mailx command in shell script.
    Thanks,
    Suman.

    Wrong forum where to ask such questions.
    Check this one link:
    http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254

  • HT1355 How to send 2 or more pdf files in e mail

    How to send 2 or more pdf files in e mail...????????

    Also i have a workspace created in html.oracle.com in that when i want to upload excel file or copy data from excel i am getting error as......
    ORA-20001: create_table error: ORA-20001: Excel load run ddl error: ORA-01658: unable to create INITIAL extent for segment in tablespace FLOW_6868Looks like the data you're trying to load will exceed your workspace quota (2MB small, 5MB medium). Try loading fewer rows.

  • I want to have Mail list Received e-mails chronologically without attaching new e-mails received to older e-mails from the same recipient.  Is their a Preferences setting or a toggle to set this?

    I want to have Mail list Received e-mails chronologically without attaching new e-mails received to older e-mails from the same recipient/with the same title.  Is there a Preferences setting or a toggle to set this?

    View menu.
    Uncheck "Organize by Conversation."
    Regards,
    Barry
    BTW: Mail is part of the bundled "System software" and is discussed in the community for your version of OS X:
    Mac OS X v10.7 Lion
    The link will take you there.
    Edit: I see someone has requested a transfer, and this conversation is now in the correct space.
    Barry

  • How to set the transition duration of a slide in keynote with applescript

    hi
    how to set the transition duration of a slide in keynote with applescript
    i made an applescript script which converts a numbers file to a keynote presentation
    figured out how to set the transitions but cant find how to set the time
    +set appTransition of slideTransition of current slide to "apple:dissolve"+
    anyone?

    you can send keystrokes to invoke menu commands via shortcuts but as for transition time not sure. You've check the dictionary right? Scripting support is very limited in KN.

  • How to send a picture as an attachment

    I'm new here and not sure I'm in the correct place .
    I just bought a imac and I'm trying to send a picture as an attachment. I showes up in the body of the email. How do I get it to be just an attachment like on a computer?

    Try using the Finder Compress the file, then attach the resultant file to the e-mail.

  • How to send a project containing multiple pictures by e-mail?

    I have previously used Photoshop Album 2.0 on PC, and have just purchased an iMac and the PSE 6.0 for it.
    I have a leisure-time project at hand, where I would like to send some 30 pictures for review for some people.
    With Photoshop Album, I could in similar cases include all the photos in a collection and then make a small slide show out of it. the size was circa 2 Mb, with music included. Now when I try to do the same in PSE 6.0, the file size is 38 Mb. That is WAY too big to be sent my e-mail.
    What do you suggest - how could I send multiple small resolution pictures by e-mail? I do not want to use web gallery. The pictures do not need to be of high resolution, but something more than thumbnails still.

    Responding to "is it safe"...
    With Flickr or JAlbum you upload your images to a web host and provide a link so another person can view those pictures. Both programs have built-in ftp functions so they upload for you.
    I can't think of anything about either that would be unsafe, but your images could be viewed by complete strangers if you don't mark them "private". Normally, you wouldn't care who views your images.
    Google Flickr and JAlbum and follow the steps to set up the program. Both very simple. These are just two suggested ways to put your images up for review by other people. There are dozens of other ways to do it. These two are free and simple to use.
    If you do want to work in Elements, and send the results as an attachment to email, then a slideshow saved in the .pdf format is the best solution.
    If your images are 2mb, then you are trying to send images that are about 2000 px x 3000 px right out of the camera. That's a 10" x 6.5" image at 300 dpi. Your viewer doesn't need that large a file to see the image.
    Resize those images to, say, 500 px on the longest side and your viewer will still see the same image in the same detail on his screen. The file will be just over 100 kb.
    Save your original in the 2mb size, and use Save As with a different file name for the reduced size images you'll send.

  • How to send an ouput as PDF attachment to email

    Hi,
    We have a 'Z' output for a delivery document. The output has the standard RLE_DELNOTE driver program and a Zsmart form assigned to it. We need to send the output as an attachment to email. Can some one please adivice how this can be achieved?
    Thanks in advance
    Kat

    Hi,
    Plz try following steps.
    1. Note the spool request No.
    2. In T/code SE38, Enter The programme and execute.
    3. In sub Object- Click Documentation and then do debuggung.
    4.Enter spool request no and desired location and execute.
    5. In ABAP Debugger- Use F8 key.
    6. Select the desired location and file name and save.
    View the desired output in PDF and can be sent through mail.
    Hope this helps.
    Regards,
    Jaiprakash.P.T

  • How to send PDF file as an attachment in email?

    Hi Folks,
    I have successfully configured SMTP and by now I can successfully send normal text messages along with .TXT files. However, when I am trying to send an email along with .pdf file as an attachment, I am getting the mail in my inbox, but I cannot open the .pdf file! I am getting the following Acrobat error:
    Acrobat could not open 'abc.pdf' because it is either not a supported file type or because the file has been corrupted
    Can any help me in solving this problem?
    Thanks in advance
    Regards,
    Faisal

    Hi Vajha,
    Thanks alot for your kind reply. I also express my apologies for responding to your reply lately.
    I beleive all the links you have sent me are talking about ABAP coding. what I am interested in is,
    is there any configuration that I am missing in SCOT (Basis side)?
    Since I am not an ABAPER, so I carry out these activities.
    Can anyone please answer the following queries of mine:
    1. Can't we send any PDF attachment in a mail from R/3?
    2. Do we have to do it through coding only?
    3. In scot we have option "All formats except fllw". But it does not work for me. Any inputs?
    Thanks in advance.
    Regards,
    Faisal

  • How to send URL (of length 500 Characters) in SAP Mail??

    Hi Everybody,
    I need to send the URL in SAP mail  using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    The URL is of length 500 characters. Is there anyway I can send this URL in mail, even as attachment will do.
    The Mail is accepting 255 characters in one line. In my case I need to split it in to two lines.
    But in mail only firstline is coming as URL and next line is truncating.
    Thanks in advance.
    Praveen.

    hi prashant,
    using this function module.... when sending the url into attachement it will not take any text beyound 255 caharacters.
    so u need to split your url and add the remain to the next line of the internal table that ur passing to this FM.
    in the form where u build the table for the attachment
    FORM f_build_datatable.
    DATA: lwa_excel TYPE gty_excel,
            lwa_attach_list TYPE solisti1,
            lv_attach TYPE string,
            lv_xcnt        TYPE i.
         loop at gt_url into lwa_url
    CONCATENATE lwa_url INTO lv_attach SEPARATED BY gc_con_tab .
        CONCATENATE lv_attach gc_con_cret INTO lv_attach.
        DO.
          lwa_attach_list-line = lv_attach.
          APPEND lwa_attach_list TO gt_attach_list.
          lv_xcnt = STRLEN( lv_attach ).
          IF lv_xcnt > 255.
            lv_attach = lv_attach+255.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        CLEAR: lwa_url, lwa_attach_list.
      ENDLOOP.
    ENDFORM.                    " f_build_display_file
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 2:48 PM

  • Adapter Module Error-Sending excel file as an attachment of the mail

    Hi ,
    My scenario is as follows
    1)I am sending an excel file as an attachment of the mail.I need to read that excel attachment as a payload.
    So mail adapter is used in sender side.
      To configure this, have used standard PayloadSwapBean  module with proper module key.
      Next to convert excel to XML another custom adapter module is being used.
    Both this adapter module , I configured into the CC of sender mail adapter.
    The order in which adapter modules are being used in the sender CC are as follows
    1)localejbs/AF_Modules/PayloadSwapBean
    2)localejbs/MDPExcelToXMLConversion
    3)sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
    MDPExcelToXMLConversion-Custom adapter module written to convert excel to xml.
    I am getting the following error
    exception caught during processing mail message [4899]com.sap.aii.af.lib.mp.module.ModuleException
    And also,
    no messages in coming MONI of PI.
    Pls suggest what to do.
    Thanks
    Ayan

    Shabarish,
    Will the ordering in which the adapter modules(In this case there are two-PayloadSwapBean & MDPExcelToXML) are appearing into Module tab of sender adapter matter?
    Firstly, what is happenning
    1)If I take out the custom  adapter module MDPExcelToXML and put only PayloadSwapBean  then it is successfully converting mail attachment into the main Payload i.e PayloadSwapBean   module is working.
    2)Nextly, my local code( i.e java code without including standard Module specific method like ejbActivate(),ejbPassivate(),process()  etc etc.)) for MDPExcelToXML is successfuly converting the excel file into the XML file.Then I am making the local code into adapter module specific code and deploying that.
    A few question arises here,
    Do I need to do any specific configurations here in PI for this particular things.Maybe both the adapter module is clashing with each other.
    And also using tracing and logging into my custom adapter module code.Getting the following error,
    java.io.IOException: Unable to read entire header; 116 bytes read; expected 512 bytes#
    Thanks
    Ayan

  • How to send the entire binary file as Content in mail adapter

    Hi,
    I have the below scenario:
    A binary file is there on the XI server and this is more than 1 lines.
    This file needs to be sent across to certain email addresses via the XI interface.
    I have made the design and config and now get the the mail but so far not been able to get the file contents.
    The requiremnet is to send the entire file contents in the mail so that they appear in the body of the received mail.
    How do i do it?
    Can you please advice.
    Regards,
    Archana

    Hi,
    I am giving below the incoming mesasge details and the outgoing Mail message details.
    Sender File Adapter:
    Mesasge Content/Payload:
      <?xml version="1.0" encoding="utf-8" ?>
    - <ns:MT_Ack_Mail_In xmlns:ns="Urn:Serco-com:interface:Banking:HSBC:FileTransfer">
    - <Content>
    - <Mail>
      <Details>UNBUNOA:3HEXAGON-ABCABC10268002081201:2152+692125127893</Details>
      </Mail>
    - <Mail>
      <Details>UNH1CONTRL:2:2:UN:APACS</Details>
      </Mail>
    - <Mail>
      <Details>UCI1000246720ABC10268002HEXAGON-ABC4+C09</Details>
      </Mail>
    - <Mail>
      <Details>UNT31</Details>
      </Mail>
    - <Mail>
      <Details>UNZ1692125127893</Details>
      </Mail>
      </Content>
      </ns:MT_Ack_Mail_In>
    Receiver Mail Adapter:
    Message Content/Payload:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
      <Subject>ME-Acknowledgement</Subject>
      <From>email of from</From>
      <To>my email</To>
      </ns1:Mail>
    I need to map the contents of the incoming payload Contents/Mail/Details (all the 5 instance) to outgoing Missing Content (after To field).
    If it can be in Mail body, then it would be best else please suggest what other option can I use?
    Also, If i want the file name to be in the subject of the mail, is that possible to be picked up in the configuration?
    Please help.
    Regards,
    Archana

  • How to send any text as soap attachment without SAAJ ?

    I have to send XML or text file as an attachment in the web service, just like email attachment. Currently I am intercepting the SOAP message (sent from web service client) and then adding an attachment using SAAJ. Can we send an attachment without intercepting and SAAJ in netbeans just like how we send other data (with basic datatypes ) as parameters to the web service operation ?
    TIA.

    Wrong forum where to ask such questions.
    Check this one link:
    http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254

Maybe you are looking for

  • How to populate the field Discount Percent (DIS) in the outbound S1ORDEXC?

    Hello all, I am working with the Spec2000 to send out the IDOC S1ORDEXC. Does anyone know how to populate the field Discount Percent (DIS)? This field length of Discount Percent is 2 characters, but our customer discount in the Princing Conditions (S

  • Word Compatability with RoboHelp X3

    What versions of Microsoft Word are compatible with RoboHelp X3, in terms of converting a Web Help project to printed documentation? I know at one time it was limited to Word 2000, but I don't know if it has been expanded to include Word XP.

  • Converting pdf to word or excel

    How could i do this ?

  • DVD not playing properly.

    So I have burnt a DVD using iDVD, when I go to play it on a DVD player the video freezes at 8.50 mins (up until then it is perfect) The video last about 20 mins in total. Ive tried playing it on a year old Samsung DVD player, a DVD player built in to

  • "Automatically sync ..." is greyed out - no Syncing under Preferences

    I see someone else had this problem, but the solution confused me. In iTunes Summary my iPhone, the "Automatically sync when this iPhone is connected" is unchecked and greyed out. Another poster suggested going to Preferences > Syncing, and that seem