Thema: Delphi Outllook 365 MAPI HTML

Einzelnen Beitrag anzeigen

Benutzerbild von haentschman
haentschman

Registriert seit: 24. Okt 2006
Ort: Seifhennersdorf / Sachsen
5.289 Beiträge
 
Delphi 12 Athens
 
#1

Outllook 365 MAPI HTML

  Alt 14. Jul 2021, 15:45
Hallöle...
Nach der Umstellung auf Outlook werden meine Mails über MAPI aus dem Programm heraus im Outlook als Text interpretiert! ..selbst David konnte das! Im Client ist HTML als Standard definiert. Alle direkten Mails werden korrekt dargestellt...

Welche einfachen Möglichkeiten habe ich? Geht das mit CleverComponents an den Standard Client? Ich habe noch nichts gefunden.

Content:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
   <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
</HEAD>
<BODY LANG="de-DE" TEXT="#000000" DIR="LTR">
<TABLE COLS=2 WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 STYLE="page-break-before: always">
   <COL WIDTH=450>
   <COL WIDTH=450>
   <TR>
      <TD HEIGHT=20 BGCOLOR="#1618A1">
         <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>Blubb</FONT></P>
      </TD>
      <TD BGCOLOR="#1618A1">
         <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>Serviceauftrag Nr.: #SNR</FONT></P>
      </TD>
   </TR>
   <TR>
      <TD HEIGHT=25   BGCOLOR="#1618A1">
        <TABLE COLS=1 WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 STYLE="page-break-before: always">
           <TR>
          <TD>
               <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>Bla Str. 4</FONT></P>
            </TD>
           </TR>
           <TR>
          <TD>
               <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>08150 JwD</FONT></P>
            </TD>
           </TR>
         </TABLE>   
      </TD>
      <TD BGCOLOR="#1618A1">
         <BR>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <BR>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>Sehr geehrte Damen und Herren,</FONT></P>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>die St&ouml;rung mit der Nummer: #SNR   wurde abgeschlossen.</FONT></P>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <BR>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
        <TABLE COLS=1 WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 STYLE="page-break-before: always">
           <TR>
          <TD>
               <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>#STNAME / Filiale: #STFILIALE</FONT></P>
            </TD>
           </TR>
           <TR>
          <TD>
               <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>#STSTRASSE</FONT></P>
            </TD>
           </TR>
            <TR>
          <TD>
               <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>#STPLZ #STORT</FONT></P>
            </TD>
           </TR>
         </TABLE>   
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <BR>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <P ALIGN=LEFT><FONT FACE="Arial" SIZE=3>Wir danken f&uuml;r Ihren Auftrag.</FONT></P>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#ffffff">
         <BR>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#1618A1">
         <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>Das ist eine automatisch generierte
         Mail. Bitte antworten sie nicht darauf.</FONT></P>
      </TD>
   </TR>
   <TR>
      <TD COLSPAN=2 HEIGHT=20 BGCOLOR="#1618A1">
         <P ALIGN=LEFT><FONT FACE="Arial" COLOR="#ffffff" SIZE=3>F&uuml;r Fragen, R&uuml;ckmeldungen
         oder Informationen benutzen sie bitte die Mailadresse:
         <A HREF="mailto:bla@Blubb.de" style="color:#A9A9A9">Bla@Blubb.de</A></FONT></P>
      </TD>
   </TR>
</TABLE>
</BODY>
</HTML>
Delphi-Quellcode:
FMailStandardClient: TSendMail;
...
function TToolsMail.SendMailClient: Boolean;

  procedure FillMailRecipents;
  var
    I: Integer;
    RecipientItem: TCollectionItem;
  begin
  {$REGION 'Code'}
    FMailStandardClient.Recipients.Clear;
    for I := 0 to FMailMessage.ToList.Count - 1 do
    begin
      RecipientItem := FMailStandardClient.Recipients.Add;
      TRecipientItem(RecipientItem).Address := FMailMessage.ToList.Items[I].Email;
      TRecipientItem(RecipientItem).DisplayName := TTools.GetDocumentPathWithoutPath(TRecipientItem(RecipientItem).Address, conSEAMMailNameWithout);
      TRecipientItem(RecipientItem).RecipientType := rtPrimary;
    end;
  {$ENDREGION}
  end;

  procedure FillMailAttachments;
  var
    I: Integer;
  begin
  {$REGION 'Code'}
    FMailStandardClient.Attachments.Clear;
    for I := 0 to FAttachments.Count - 1 do
    begin
      FMailStandardClient.Attachments.Add(FAttachments[I]);
    end;
  {$ENDREGION}
  end;

  procedure FillMailBody;
  begin
  {$REGION 'Code'}
    FMailStandardClient.Subject := FMailMessage.Subject;
    FMailStandardClient.Text := FMailMessage.Html.Strings;
  {$ENDREGION}
  end;

begin
  Result := True;
  try
    FMail.Open; //CleverComponents
    try
      CreateMailMessage; //CleverComponents
      // Übertrag in TSendMail
      FillMailBody;
      FillMailRecipents;
      FillMailAttachments;

      if FMailStandardClient.Execute then
      begin
        WriteMailDB;
        if Assigned(FOnMailSend) then
        begin
          FOnMailSend(Self, FMailMessage.ToList.EmailAddresses, FMailMessage.Subject);
        end;
      end;
    finally
      FMail.Close;
    end;
  except
    on E: Exception do
    begin
      if Assigned(FOnMailError) then
      begin
        FOnMailError(Self, FReceipients, FMailMessage.Subject, E.Message);
      end;
      Result := False;
    end;
  end;
end;

Geändert von haentschman (14. Jul 2021 um 15:50 Uhr)
  Mit Zitat antworten Zitat