IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Oracle Discussion :

Problème sur script mail_files


Sujet :

Oracle

  1. #1
    Futur Membre du Club
    Inscrit en
    Décembre 2006
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Décembre 2006
    Messages : 10
    Points : 7
    Points
    7
    Par défaut Problème sur script mail_files
    Bonjour,
    J'essaie de remonter, la cause d'un problème rencontré sur le script bien connu mail_files. Ne sachant pas s'il s'agit d'un problème sur le script ou bien sur Exchange , j'en profite pour vous demander vos lumières.

    Le code suivant est utilisé pour l'envoi de mail.

    Malheureusement, le message apparait aux destinataires sans accent (é,è, î, etc.).

    J'ai bien essayé de lui indiquer le charset en iso-8859-1 et 8 bit pour le Content-Transfer-Encoding:, malheureusement sans succès.

    Avez vous des retours d'expérience par rapport à cela, et auriez vous la gentillesse de m'aiguiller sur une esquisse de solution avant que je me penche sur le serveur exchange et le protocole smtp.

    Bien à vous
    Jaskoula



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    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
     
      v_smtp_server      varchar2(100) := 'serveurmail';
      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(2000) INDEX BY binary_integer;
     
      file_array         varchar2_table;
      i                  binary_integer;
      pos_sep            Number;
      Fichiers_joints    Varchar2(1000);
     
      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 );
       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 ||
              'Content-Transfer-Encoding: 7bit' || crlf ||
    		  'X-Confirm-Reading-To:'||from_name||crlf||
    		  'Disposition-Notification-To:'||from_name||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 ||
    		  '' || 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 );
     
       -- Append the files ...
       -- ----------------
       i:=1;
       pos_sep:=1;
       Fichiers_joints:=filename1;
       IF filename1 IS NOT NULL then
       	 While pos_sep>0 Loop
    	   Pos_sep:=instr(fichiers_joints,';',1);
    	   IF pos_sep>0 Then
    	   	  File_array(1):=substr(fichiers_joints,1,pos_sep-1);
    	   Else
    	      File_array(1):=fichiers_joints;
    	   End IF;
           -- 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/pdf; name="' || v_file_name || '"' || crlf ||
                 'Content-Disposition: attachment; filename="' || v_file_name || '"' || crlf ||
                 'Content-Transfer-Encoding: 7bit' || 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
                     IF debug > 0 then
                        dbms_output.put_line('Error in opening attachment '||
                                              file_array(i) );
                     end IF;
     
                 -- 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;
    		IF pos_sep>0 Then
    		   fichiers_joints:=substr(fichiers_joints,pos_sep+1);
    		End IF;
       end loop;
       End IF;
       -- 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;

  2. #2
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 075
    Points
    19 075
    Par défaut
    quel est le CHARACTER SET de la base ?

Discussions similaires

  1. Problème sur script de démarrage de base
    Par sebio50 dans le forum Administration
    Réponses: 6
    Dernier message: 18/11/2008, 14h56
  2. problème sur script shell
    Par cyranno dans le forum Linux
    Réponses: 1
    Dernier message: 11/12/2007, 16h19
  3. [SQL] Problème avec script de pagination et requête sql sur deux tables
    Par psychoBob dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 12/06/2006, 14h06
  4. Problème sur script de news :(
    Par Anthos59 dans le forum ASP
    Réponses: 7
    Dernier message: 12/04/2006, 10h42
  5. Réponses: 3
    Dernier message: 15/02/2006, 17h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo