0

I created an email template in HTML which i call in my python code. I prepare the mail in python using MIMEMultipart() and sending it afterwards via SMTP server to Microsoft Outlook.

For the tabulator space i tried following:

            <span style="margin-left:400px;">myText</span>

When i view the HTML in the browser i get the 400px space from the left side. But when i am trying to send the HTML via email it is ignoring the spacing.

This is my code:

<html xmlns:v="urn:schemas-microsoft-com:vml"
      xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:w="urn:schemas-microsoft-com:office:word"
      xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
      xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
      xmlns="http://www.w3.org/TR/REC-html40">

<head>
    <meta http-equiv=Content-Type content="text/html"; charset="UTF-8">
    <style>
       
    </style>
</head>

<body lang=DE link=blue vlink=purple style='tab-interval:35.4pt;word-wrap:break-word'>
    <div class=WordSection1>        
<p class=MsoNormal>
            <span lang=EN-US style='mso-ansi-language:EN-US'>
            myText
            <span style="margin-left:400px;">myText</span>
            myText
            </span>
        </p>
    </div>
</body>
</html>
asdf1234
  • 11
  • 2
  • Does this answer your question? [HTML margins not supported in Outlook](https://stackoverflow.com/questions/20347803/html-margins-not-supported-in-outlook) – isherwood May 11 '23 at 14:53
  • Or this? [CSS padding is not working as expected in Outlook](https://stackoverflow.com/questions/21474239/the-css-padding-is-not-working-in-outlook) – isherwood May 11 '23 at 14:54
  • 1
    use **table** for designing a template for outlook – Ali Sheikhpour May 11 '23 at 15:07
  • I checked both links and when i am using the
    tag i get the spacing, but my text gets apart in 3 lines because it ist spacing also top and bottom and not only on the left side.
    – asdf1234 May 11 '23 at 15:21
  • @AliSheikhpour what do you mean by using table for designing? – asdf1234 May 11 '23 at 15:21
  • 1
    Use a table as main element and manage the spaces using empty TD elements. `Margin` not works in outlook. – Ali Sheikhpour May 11 '23 at 15:23
  • That's an great idea. Thanks a lot @AliSheikhpour! – asdf1234 May 11 '23 at 15:42
  • Also check your CSS. tab-interval is not a valid CSS constructor. You can find all the HTML and CSS you can use _safely_ in E-Mails at https://www.caniemail.com/ – rx2347 May 11 '23 at 17:24
  • @rx2347 Great link, thanks! The table element is supported – asdf1234 May 15 '23 at 16:02

0 Answers0