Attach file to mail with "unusual" characters

Hi
I have made a procedure that can send mail with attached file/files. But when I attach a text file that contains characters like (Å, Ä or Ö) these characters gets like (A, A and ?) when I recieve the mail to my mail client. When I look at the file on the disk before I attach it the characters is OK but when I attach the file and mails it the characters get replaced. So why does the charaters get messed up when I attach the file to a mail??
My procedure looks like this:
procedure mail_files(from_name varchar2,
to_name varchar2,
subject varchar2,
message varchar2,
max_size number default 9999999999,
filename1 varchar2 default null,
filename2 varchar2 default null,
filename3 varchar2 default null,
debug number default 0) is
mottagare VARCHAR2(2048) := to_name;
v_smtp_server varchar2(32) := 'mail.telia.se';
v_smtp_server_port number := 25;
v_directory_name varchar2(100);
v_file_name varchar2(100);
v_line varchar2(1000);
crlf varchar2(2) := chr(13) || chr(10);
mesg varchar2(32767);
conn UTL_SMTP.CONNECTION;
type varchar2_table is table of varchar2(200) index by binary_integer;
file_array varchar2_table;
i binary_integer;
v_file_handle utl_file.file_type;
v_slash_pos number;
mesg_len number;
mesg_too_long exception;
invalid_path exception;
mesg_length_exceeded boolean := false;
begin
-- first load the three filenames into an array for easier handling later ...
file_array(1) := filename1;
file_array(2) := filename2;
file_array(3) := filename3;
-- Open the SMTP connection ...
conn := utl_smtp.open_connection(v_smtp_server, v_smtp_server_port);
-- Initial handshaking ...
utl_smtp.helo(conn, v_smtp_server);
utl_smtp.mail(conn, from_name);
WHILE (mottagare IS NOT NULL) LOOP
utl_smtp.rcpt(conn, get_element(mottagare));
END LOOP;
--utl_smtp.rcpt( conn, to_name );
utl_smtp.open_data(conn);
-- build the start of the mail message ...
mesg := 'Date: ' || TO_CHAR(SYSDATE, 'dd Mon yy hh24:mi:ss') || crlf ||
'From: ' || from_name || crlf || 'Subject: ' || subject || crlf ||
'To: ' || to_name || crlf || 'Mime-Version: 1.0' || crlf ||
'Content-Type: multipart/mixed; boundary="DMW.Boundary.605592468"' || crlf || '' || crlf ||
'This is a Mime message, which your current mail reader may not' || crlf ||
'understand. Parts of the message will appear as text. If the remainder' || crlf ||
'appears as random characters in the message body, instead of as' || crlf ||
'attachments, then you''ll have to extract these parts and decode them' || crlf ||
'manually.' || crlf || '' || crlf ||
'--DMW.Boundary.605592468' || crlf ||
'Content-Type: text/html; charset=8859-1' || crlf ||
'Content-Disposition: inline;' || crlf ||
'Content-Transfer-Encoding: 8bit' || crlf || '' || crlf ||
message || crlf;
mesg_len := length(mesg);
if mesg_len > max_size then
mesg_length_exceeded := true;
end if;
utl_smtp.write_data(conn, mesg);
--utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(mesg));
-- Append the files ...
for i in 1 .. 3 loop
-- Exit if message length already exceeded ...
exit when mesg_length_exceeded;
-- If the filename has been supplied ...
if file_array(i) is not null then
begin
-- locate the final '/' or '\' in the pathname ...
v_slash_pos := instr(file_array(i), '/', -1);
if v_slash_pos = 0 then
v_slash_pos := instr(file_array(i), '\', -1);
end if;
-- separate the filename from the directory name ...
v_directory_name := substr(file_array(i), 1, v_slash_pos - 1);
v_file_name := substr(file_array(i), v_slash_pos + 1);
-- open the file ...
v_file_handle := utl_file.fopen(v_directory_name, v_file_name, 'r');
-- generate the MIME boundary line ...
mesg := crlf || '--DMW.Boundary.605592468' || crlf ||
'Content-Type: application/octet-stream; name="' ||
v_file_name || '"' || crlf ||
'Content-Disposition: attachment; filename="' ||
v_file_name || '"' || crlf ||
'Content-Transfer-Encoding: 8bit' || crlf || crlf;
mesg_len := mesg_len + length(mesg);
utl_smtp.write_data(conn, mesg);
-- and append the file contents to the end of the message ...
loop
utl_file.get_line(v_file_handle, v_line);
if mesg_len + length(v_line) > max_size then
mesg := '*** truncated ***' || crlf;
utl_smtp.write_data(conn, mesg);
mesg_length_exceeded := true;
raise mesg_too_long;
end if;
mesg := v_line || crlf;
utl_smtp.write_data(conn, mesg);
mesg_len := mesg_len + length(mesg);
end loop;
exception
when utl_file.invalid_path then
-- All other exceptions are ignored ....
when others then
null;
end;
mesg := crlf;
utl_smtp.write_data(conn, mesg);
-- close the file ...
utl_file.fclose(v_file_handle);
end if;
end loop;
-- append the final boundary line ...
mesg := crlf || '--DMW.Boundary.605592468--' || crlf;
utl_smtp.write_data(conn, mesg);
-- and close the SMTP connection ...
utl_smtp.close_data(conn);
utl_smtp.quit(conn);
end;
Any help is highly appreciated.
Regards
Nils

Hi Madhu,
     Using the default modules PayloadSwapBean and MessageTransformBean you can able to send multiple attachments.
swap.keyName  :payload-name or payload-description or content-type, content-description. swap.keyValue: If you have  a multiple attachments then give the multiple key value.
Like you have payload name
  Attachment1, Attachment2 then
swap.keyName  payload-name
swap.keyValue  Attachment1, Attachment2
Using the MessageTransformBean you can able to change the file name.
PayloadSwapBean:
[http://help.sap.com/saphelp_nw70/helpdata/EN/2e/bf37423cf7ab04e10000000a1550b0/content.htm]
MessageTransformBean:
[http://help.sap.com/saphelp_nw70/helpdata/EN/57/0b2c4142aef623e10000000a155106/content.htm]
Regards,
Prakasu

Similar Messages

  • How to attach files to mail

    When I attach files to mails (.pdf, .jpg, .docx etc.), they arrive in Windows Outlook embedded. My mail settings are "Always Send Windows-Friendly Attachments" and "Always Insert Attachments at End of Message".
    I know how to open these attachments in Windows Outlook but my recipients do not. To suggest that they learn how to, as I have seen in some places, is arrogant. If I apply for a job by email and attach my resume with instructions on how to open it will reduce my chances of getting that job close to zero.
    How can I attach files that will be received as files and can be opened by the MS Windows recipient with left mouse clicks?

    Another way to send files to others is to use Dropbox.
    In your email you don't attach the file, but rather include a link that you reciepeints then use to download the file.
    I use this method for particularly large files, but it can be used for any file.
    Matt

  • Can't attach file in mail since the last update

    Have updated the IOS to 10.8.5, ever since , I'm not able to attach files to mail ....... Any solutions ?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Convert Script output data to Text(.txt) file & send mail with attachment.

    Hi All,
    Requirement: I shulb be able to conver th Script output data to Text(.text) file & send a maill with attachment with this text file. Formant of text file should be like output of Print priview.
    Plese sugget with Function modules to cover as Text file.
    I am able to converting the Script output data to PDF and sending mail with attachment. So I don't want PDF file now.
    Thanks in advance.

    Hi, Thanks for responst.
    We can convert the Scirpt output to PDF file by using OTF function module and the PDF file looks like Print Privew output.
    Same like this I want Script out in NOTEPAD (.txt). Is that possible, Plz sugget with relavent Function Modules.
    Thanks.

  • File to Mail with XML Attachment

    Hi Ravi,
    Just have look into the configuration of sender file adapter configuration.
    The sender file adapter is configured to pick the normal payload, which is specified in the File access parameters, and the additional image file  that is to be sent as an attachment is configured under the Additional File(s).The file type would still remain binary.
    Also check out the Module c onfiguration if you did it correctly and check out the transform.ContentType values inside.
    Hope this will help you.
    Regards
    Aashish Sinha

    Hi Shabarish,
    In the module tab i have specified the below beans
    localejbs/AF_Modules/MessageTransformBean                           contentType
    AF_Modules/PayloadZipBean                                                    zip
    sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean           mail
    In the module configuration i mentioned as
    Transform.ContentDescription   file
    Transform.ContentDisposition   attachment:filename="file.xml"
    zip.filenameKey                      contentType
    zip.mode                                zipOne
    Now i am getting the mail with zip file as an attachment.But the name of the attachment i got is MainDocument.zip
    Even the file name inside the zip is MainDocument.xml.
    How can i specify my own file name for both zip file and the file inside the archieve folder.Please help me.
    Regards
    Divia

  • Problem with attaching files to mail message

    Hello,
    I have problem with my mail app. I'm using spaces for better organization. When I wanna add some file to mail message I usually go to different desktop (space), where I have the file I wanna attach. I grab it move to right up corner to activate spaces, than move to desktop (space) with mail.app and press spacebar (it activates the desktop immediately). At that time it also start random app, which is in my dock.
    You can see it in my youtube video.
    How can avoid this strange thing happen?
    http://www.youtube.com/watch?v=KUypUnPHZvc
    I'm using MacBook Pro 15'', Snow Leopard - latest updates. I've reinstalled my mac two days ago, so no garbage should be in.

    Thanks for quick reply.
    I don't have selected "always..." so I also tried it with selected "always...".
    Now I discovered that it has nothing to do with the mail. I've tried just move some file from one of spaces (desktop) to another using the spacebar for faster switching and it did the same. It opens random app from Dock.
    So now this topic is in wrong discussion. I will post it to correct discussion...

  • File to Mail with content as excel attachment

    Hi there,
    Can somebody please guide me in achieving this goal.
    I have a requirement in which I have to send the email content as an excel attachment which is very new to me.
    Requirement
    File.............XI............Mail
    Sender File: xyz.xml
    Mapped with standard mail.xsd and concat all the requested filed to the content but now the requirement is changed and I need to send the content as an excel attachment.
    I don't know JAVA & ABAP and this is the first time I am using mail adapter.
    Can somebody please guide me how to achieve this.
    In Another interface I have to send the source file name as a mail attachment, By Default mail adapter send the filename as untitled.
    Is there easy way to changed the name of the attachment to the source file name.
    File ............... XI.........Mail.
    Source file: xyz.xml
    No mapping required just send the file to the mail adapter but condition is that the file name should be the same.
    Mail (Attachment: xyz.xml)
    Please can somebody suggest me how to achieve this.
    Thanks,

    Hi,
    Please refer the blogs given which help you a lot regarding your requirement.
    /people/community.user/blog/2006/09/08/email-report-as-attachment-excelword
    /people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
    /people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    /people/sravya.talanki2/blog/2006/01/12/xi-triggering-e-mails-with-multiple-attachments--problems

  • Convert Screen(spool) to PDF file sending mail with attach file

    Hi :
    I'd like convert spool list to pdf and sending file...
    so, I read thread about spool convert to PDF before,
    and know how to convert Spool to PDF file and send mail with attach file.
    but I have a problem.
    my solution as:
    step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
    step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
    then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
    I want to showing word is wider that 255.
    and then I find a manual method as:
    After program finished.
    Function Menu -> system -> List -> Send
    use Prog: "Create Document and Send"
    I use this prog sending mail and attached file ,
    PDF file do <b>NOT</b> have 255 word limit !
    finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
    which Function I have to use?...
    Please help me, Thanks!

    Hi,
    Check this sample code of sending spool as attachment to an email address..
    Parameters.
    PARAMETERS: p_email(50) LOWER CASE.
    PARAMETERS: p_spool LIKE tsp01-rqident.
    Data declarations.
    DATA: plist         LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: document_data LIKE sodocchgi1.
    DATA: so_ali        LIKE soli OCCURS 100 WITH HEADER LINE.
    DATA: real_type     LIKE soodk-objtp.
    DATA: sp_lang       LIKE tst01-dlang.
    DATA: line_size     TYPE i VALUE 255.
    DATA: v_name        LIKE soextreci1-receiver.
    DATA rec_tab        LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    Get the spool data.
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
         EXPORTING
              rqident              = p_spool
              first_line           = 1
              last_line            = 0
              desired_type         = '   '
         IMPORTING
              real_type            = real_type
              sp_lang              = sp_lang
         TABLES
              buffer               = so_ali
         EXCEPTIONS
              no_such_job          = 1
              job_contains_no_data = 2
              selection_empty      = 3
              no_permission        = 4
              can_not_access       = 5
              read_error           = 6
              type_no_match        = 7
              OTHERS               = 8.
    IF sy-subrc <> 0.
      MESSAGE s208(00) WITH 'Error'.
      LEAVE LIST-PROCESSING.
    ENDIF.
    Prepare the data.
    plist-transf_bin = 'X'.
    plist-head_start = 0.
    plist-head_num = 0.
    plist-body_start = 0.
    plist-body_num = 0.
    plist-doc_type = 'RAW'.
    plist-obj_descr = 'Test ALV'.
    APPEND plist.
    plist-transf_bin = 'X'.
    plist-head_start = 0.
    plist-head_num = 0.
    plist-body_start = 1.
    DESCRIBE TABLE so_ali LINES plist-body_num.
    plist-doc_type = real_type.
    Get the size.
    READ TABLE so_ali INDEX plist-body_num.
    plist-doc_size = ( plist-body_num - 1 ) * line_size
                     + STRLEN( so_ali ).
    APPEND plist.
    Move the receiver address.
    MOVE: p_email  TO rec_tab-receiver,
          'U'      TO rec_tab-rec_type.
    APPEND rec_tab.
    IF NOT sp_lang IS INITIAL.
      document_data-obj_langu = sp_lang.
    ELSE.
      document_data-obj_langu = sy-langu.
    ENDIF.
    v_name = sy-uname.
    Send the email.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
         EXPORTING
              document_data              = document_data
              sender_address             = v_name
              sender_address_type        = 'B'
         TABLES
              packing_list               = plist
              contents_bin               = so_ali
              receivers                  = rec_tab
         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.
    IF sy-subrc <> 0.
      MESSAGE e208(00) WITH 'Error'.
    ENDIF.
    COMMIT WORK.
    Send the email immediately.
    SUBMIT rsconn01
    WITH mode = 'INT'
    AND RETURN.
    Thanks,
    Naren

  • Cannot save attached files in Mail

    My problem has to do with using the Mail program on a MacBook Pro running Mavericks. Lately when I receive an email with a file attachment (image, Word doc, PPT file, whatever) I cannot save the attached file. 
    I point to the attachment "download" dialog box, and choose either the "save all" option or the specific attachment filename shown, then navigate to the desired folder and hit "save".  But no file is created. 
    The attachments are there - if I look at the same email using the gmail web-based mail utility I can easily download it. It's a problem with the Apple Mail client.
    Any suggestions?  Thank you.
    Jerry

    Zips and other archived/compressed files won't work as expected on an iPad since you can't just preview/view the contents directly from the attachment currently like you can with quicktime-compatible or other common media formats. Basically you would need to be able to save the zip file to the finder and extract it, and view the contents from there. But since the iPad doesn't have anything like a user-accessible Finder, it's tricky to implement.
    There may be third-party apps that deal with this eventually (or maybe even something from the upcoming 4.0 software, who knows), but it would probably be easier to just have people send you attachments that aren't zipped up for now.

  • Attaching files to Mail

    In the last 2 days I have not been able to attach files to outgoing mail.  I click on the paperclip icon, but no new screen pops up.  Any solutions?

    Let's go back to your original problem.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Mail with Asian Characters Flagged As Spam

    Hi,
    I'm based out in Asia, and quite a few of my customers get email in their mother tongue, and most of it seems to be incorrectly flagged as spam due to the asian characters etc.
    An example from the logs would be:
    hits=12.439 tag=-999 tag2=3 kill=8 tests=BAYES_99, CHARSETFARAWAYHEADER, HELOEQJP, HELOEQ_NEJP, HOSTEQJP, HOSTEQ_NEJP, NOREALNAME, RELAYIS203, quarantine spam-ff2272f20c18bcfcad34405e0d7245b9-20061216-060809-13862-01 (spam-quarantine)
    Now, my question is WHERE do I find the correct file to turn this off.
    I do have some rules in: /etc/mail/spamassassin (including some I have added myself from spamemporium, or whatever) but I can't find anything in any of the files that deals with "Asian Stuff"
    Help! I'm about to lose a customer, as all his Japanese email is flagged as spam! Appreciate any guidance you can give.
    Cheers,
    Steve

    HELOEQ_NEJP
    HOSTEQJP
    HOSTEQ_NEJP
    HELOEQJP
    are all in this ruleset:
    88FVGTheaders.cf
    (which you added yourself)
    The older FVGT rulesets quite often tend to overly aggressive. Also, this has been replaced by a newer version "00FVGTFile001.cf" which doesn't contain those rules anymore.
    Either lower the scores for these rules or remove/replace the ruleset.
    To lower scores, just add:
    score HELOEQ_NEJP 0.0
    (and so on)
    to your local.cf or user_prefs file.
    Alex

  • File to Mail with multiple attachments

    Hi All,
    I am doing file to mail scenario in which iam including attachments.
    I am able to send one attachment(i.e., .txt) from file to mail.
    My requirement is i need to send both .txt and .xls .Please let me know the procedure for sending multiple attachments(probabaly without any abap coding or .jar files usage).
    regards
    Madhu

    Hi Madhu,
         Using the default modules PayloadSwapBean and MessageTransformBean you can able to send multiple attachments.
    swap.keyName  :payload-name or payload-description or content-type, content-description. swap.keyValue: If you have  a multiple attachments then give the multiple key value.
    Like you have payload name
      Attachment1, Attachment2 then
    swap.keyName  payload-name
    swap.keyValue  Attachment1, Attachment2
    Using the MessageTransformBean you can able to change the file name.
    PayloadSwapBean:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/2e/bf37423cf7ab04e10000000a1550b0/content.htm]
    MessageTransformBean:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/57/0b2c4142aef623e10000000a155106/content.htm]
    Regards,
    Prakasu

  • Unable to attach files in mail and unable to print from browser

    while trying to attach files it is not opening the path in mozilla. and uable to print directly from browser.

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings and disables most add-ons (extensions and themes).
    ''(If you're using an added theme, switch to the Default theme.)''
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu by clicking on the '''Restart with Add-ons Disabled...''' menu item:<br>
    [[Image:FirefoxSafeMode|width=520]]<br><br>
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.
    Thank you.

  • Problems reading attached files in Mail 5.2

    After moving messages from inbox to different mailboxes, it sometimes happens that the attached file (exel, word...) disappears as an attachment and is no longer readable. > The content converts itself as a long text looking like this "CBAAAAYFAOwVzQfBwAAABgMAAOEAAgCwBMEAAgAAAOIAAABcAHAADQAAYWRtaW5pc3Ry...." and I can no longer save the file because it has disappeared!!!
    I don't want to PRINT or SAVE every attachment. I just want to keep the message as long as I might need it's content. But this is no longer possible nor reliable.
    CAN SOMEONE HELP ME??? Thank you :-)

    Disable Mac Mail.app Inline Image Attachments
    http://micahgilman.com/play/disable-mac-mailapp-inline-image-attachments/
    Force Apple mail.app to display attachments as icon
    http://www.sant-media.co.uk/2010/11/apple-mail-inline-attachments/
    Mail.app attachment as icon
    http://creativebits.org/mac_os_x/mail_app_attachment_as_icon/

  • How do you attach files in mail only as icons?

    When I am attaching files (in particular PDF's or Power Point) to an email message  in Apple mail the file is opened and attached to the end of the message.
    How can I attach it only as an icon or convert it to an icon.

    I tried your suggestion on "compressing the file' in Finder and it attached the zip file.  The only problem is it created an additional file (zipped) on my drive.
    Thanks

Maybe you are looking for