Bonjour , je souhaiterais modifier ce morceau de code afin d'envoyer mon mail sous format html.
quelqu'un aurait une idée?


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
 function EnvoyerMails( const SDestinataire, SSujet, STexte : String;
                      LFichiers: TStringList;
                      BAfficherErreur : Boolean = True;
                      BEnvoiAuto : Boolean = False ) : Boolean;
var
   DD : Array[0..9]Of MapiRecipDesc;
   Exp : MapiRecipDesc;
   DF : array[ 0..49 ] of MapiFileDesc; // description fichier, 50 maxi.
   DM : MapiMessage; // description du message
   IError : Cardinal;
   MailHandle : THandle;
   i: Integer;
 
   j, nbrTo : integer;
   dest : TstringList;
 
begin
   Result := False;
   if LFichiers.Count > 50 then
     begin
     ShowMessage( '50 fichiers joints maxi. Opération annulée' );
     Exit;
     end;
 
   // Destinataire
   if SDestinataire <> '' then
   begin
 
    dest := TStringList.Create;
    dest.Clear;
 
    dest.Text := StringReplace(trim(SDestinataire), ';', sLineBreak, [rfReplaceAll]);
 
    nbrTo := dest.Count;
 
    if nbrTo > 10 then
     begin
     ShowMessage( '10 Destinataires maxi. Opération annulée' );
     Exit;
     end;
 
 
    for j:=0 to nbrTo-1 do
    begin
     DD[j].ulReserved := 0;
     DD[j].ulRecipClass := MAPI_TO;
     DD[j].lpszName := PChar(dest[j]);
     DD[j].lpszAddress := nil;
     DD[j].ulEIDSize := 0;
     DD[j].lpEntryID := nil;
    end;
 
   end;
   // Fichier joint
   if LFichiers.Count > 0 then
     for i := 0 to LFichiers.Count - 1 do
       with DF[ i ] do
         begin
         ulReserved := 0;
         flFlags := 0;
         nPosition := $FFFFFFFF;
         lpszPathName := StrNew( PChar( ExpandUNCFileName( LFichiers[ i ] ) )) ; // Chemin + fichier
         lpszFileName := StrNew( PChar( ExtractFileName( LFichiers[ i ] ) ) ); // Fichier uniquement
         lpFileType := nil;
         end;
   // Message
   with DM do
     begin
     ulReserved := 0;
     lpszSubject := PChar( SSujet );
     lpszNoteText := PChar( AdjustLineBreaks( STexte ) );
     lpszMessageType := nil;
     lpszDateReceived := nil;
     lpszConversationID := nil;
     flFlags := 0;
 
     lpOriginator := nil;
 
     if SDestinataire <> '' then
       begin
       nRecipCount := dest.Count;
       lpRecips := @DD
       end
     else
       begin
       nRecipCount := 0;
       lpRecips := Nil;
       end;
     if LFichiers.Count > 0 then
       begin
       nFileCount := LFichiers.Count;
       lpFiles := @( DF[0] );
       end
     else
       begin
       nFileCount := 0;
       lpFiles := nil;
       end;
     end;
     if MapiLogOn(0,nil,nil,0,0,@MailHandle)=0 then
  //     if MailLogon( MailHandle, BAfficherErreur ) then
     try
     // Envoi du mail
     //BEnvoiAuto := False;
 
     if BEnvoiAuto
       then IError := MapiSendMail( MailHandle, Application.Handle, DM, 0, 0 )
       else IError := MapiSendMail( MailHandle, Application.Handle, DM, MAPI_DIALOG , 0 );
     //Result := SErreurSendMail( IError ) = '';
     //if ( not Result ) and BAfficherErreur
 
 
     if ((IError <> SUCCESS_SUCCESS) and BAfficherErreur) then
        ShowMessage( 'ERREUR d''envoi du mail vers ' + SDestinataire + #13 +
         IntToStr(IError));
                        // SErreurSendMail( IError ) );
     finally
     MapiLogOff(MailHandle,0,0,0);
     //MailLogoff( MailHandle );
     end;
   // Libérations
   for i := 0 to LFichiers.Count - 1 do
     begin
     StrDispose( DF[ i ].lpszPathName );
     StrDispose( DF[ i ].lpszFileName );
     end;
  end;
Je vous remercie d'avance.

Cordialement,
Angelique