# HTML E-postayı C# String'e Çevir | MailCraft Studio

> HTML e-posta şablonunu, tırnakları ikilenmiş ve CSS süslü parantezleri kaçırılmış bir C# $@"…" interpolated verbatim string'e çevirin; .NET mail kodunuza doğrudan yapıştırın.

Source: https://mailcraftstudio.com/tools/html-email-to-csharp

# HTML e-postayı C# string'e çevir

Şablonu yapıştırın, C# koduna hazır çıktıyı alın. Dönüşüm tarayıcınızda yapılır.

HTML e-posta

<!DOCTYPE html> <html lang="tr" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="color-scheme" content="light dark"> <meta name="supported-color-schemes" content="light dark"> <title>Siparişin yolda: #{order.no}</title> <!--\[if mso\]><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><!\[endif\]--> <style> :root { color-scheme: light dark; supported-color-schemes: light dark; } a { color: #1d5fd6; } @media (max-width: 620px) { .px { padding-left: 22px !important; padding-right: 22px !important; } .col { display: block !important; width: 100% !important; max-width: 100% !important; } .h1 { font-size: 28px !important; line-height: 34px !important; } .hide-sm { display: none !important; } } @media (prefers-color-scheme: dark) { .page { background: #0c111b !important; } .card { background: #151b27 !important; } .ink { color: #edf1f7 !important; } .muted { color: #a8b2c3 !important; } .line { border-color: #2a3243 !important; } .soft { background: #1c2333 !important; } } </style> </head> <body class="page" style="margin:0;padding:0;background:#eef2f8;"> <div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">Tahmini teslim {order.eta}.&#8199;&#847;&#8199;&#847;&#8199;&#847;&#8199;&#847;&#8199;&#847;</div> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" class="page" style="background:#eef2f8;"> <tr> <td align="center" style="padding:32px 12px;"> <!--\[if mso\]><table role="presentation" width="600" cellpadding="0" cellspacing="0"><tr><td><!\[endif\]--> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="max-width:600px;"> <tr> <td class="px" style="padding:0 8px 18px;"> <table role="presentation" cellpadding="0" cellspacing="0"> <tr> <td width="28" height="28" style="width:28px;height:28px;background:#1d5fd6;border-radius:8px;font-size:0;line-height:0;">&nbsp;</td> <td class="ink" style="padding-left:10px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;font-weight:bold;letter-spacing:-0.2px;color:#131a2a;">{app.name}</td> </tr> </table> </td> </tr> <tr> <td class="card" style="background:#ffffff;border-radius:18px;"> <table role="presentation" width="100%" cellpadding="0" cellspacing="0"> <tr><td class="px" style="padding:36px 44px 12px;"> <h1 class="h1 ink" style="margin:0 0 14px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:32px;line-height:38px;font-weight:bold;letter-spacing:-0.6px;color:#131a2a;">Siparişin yola çıktı.</h1> <p class="muted" style="margin:0 0 18px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;line-height:25px;color:#4d586b;">Merhaba {customer.name}, #{order.no} numaralı siparişin kargoya verildi.</p> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:8px 0 26px;"> <tr><td class="soft" style="padding:22px 24px;background:#eaf1fd;border-radius:14px;"> <p class="muted" style="margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#5d6b85;">Tahmini teslim</p> <p class="ink" style="margin:0 0 18px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:30px;line-height:36px;font-weight:bold;letter-spacing:-0.5px;color:#131a2a;">{order.eta}</p> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:0 0 8px;"><tr> <td width="25%" style="padding:0 4px 0 0;"><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td class="" style="height:8px;background:#1d5fd6;border-radius:4px;font-size:0;line-height:0;">&nbsp;</td></tr></table></td> <td width="25%" style="padding:0 4px 0 0;"><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td class="" style="height:8px;background:#1d5fd6;border-radius:4px;font-size:0;line-height:0;">&nbsp;</td></tr></table></td> <td width="25%" style="padding:0 4px 0 0;"><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td class="soft" style="height:8px;background:#dfe5ee;border-radius:4px;font-size:0;line-height:0;">&nbsp;</td></tr></table></td> <td width="25%" style="padding:0 0px 0 0;"><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td class="soft" style="height:8px;background:#dfe5ee;border-radius:4px;font-size:0;line-height:0;">&nbsp;</td></tr></table></td> </tr><tr> <td valign="top" class="ink" style="padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#131a2a;">Alındı</td> <td valign="top" class="ink" style="padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;font-weight:bold;color:#131a2a;">Kargoda</td> <td valign="top" class="muted" style="padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#8a94a6;">Dağıtımda</td> <td valign="top" class="muted" style="padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#8a94a6;">Teslim</td> </tr></table> </td></tr> </table> <!--\[if mso\]><table role="presentation" width="100%" cellpadding="0" cellspacing="0"><tr><td width="50%" valign="top"><!\[endif\]--> <div class="col" style="display:inline-block;width:100%;max-width:244px;vertical-align:top;"><p class="muted" style="margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#7a8597;">Kargo firması</p><p class="ink" style="margin:0 0 20px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:bold;color:#131a2a;">{shipping.carrier}</p></div><!--\[if mso\]></td><td width="24"></td><td width="50%" valign="top"><!\[endif\]--><div class="hide-sm" style="display:inline-block;width:24px;font-size:0;">&nbsp;</div><div class="col" style="display:inline-block;width:100%;max-width:244px;vertical-align:top;"><p class="muted" style="margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#7a8597;">Takip numarası</p><p class="ink" style="margin:0 0 20px;font-family:'Courier New',Courier,monospace;font-size:15px;font-weight:bold;color:#131a2a;">{shipping.trackingNo}</p></div> <!--\[if mso\]></td></tr></table><!\[endif\]--> <table role="presentation" cellpadding="0" cellspacing="0" style="margin:6px 0 26px;"> <tr><td> <!--\[if mso\]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{order.trackingUrl}" style="height:50px;v-text-anchor:middle;width:220px;" arcsize="24%" stroke="f" fillcolor="#1d5fd6"><w:anchorlock/><center style="color:#ffffff;font-family:Arial,sans-serif;font-size:16px;font-weight:bold;">Kargoyu takip et</center></v:roundrect><!\[endif\]--> <!--\[if !mso\]><!--><a href="{order.trackingUrl}" style="display:inline-block;background:#1d5fd6;color:#ffffff;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;font-weight:bold;line-height:50px;padding:0 30px;border-radius:12px;text-decoration:none;">Kargoyu takip et</a><!--<!\[endif\]--> </td></tr> </table> </td></tr> </table> </td> </tr> <tr> <td class="px muted" style="padding:22px 44px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:19px;color:#7a8597;">Bu e-postayı bir sipariş verdiğin için aldın.</td> </tr> </table> <!--\[if mso\]></td></tr></table><!\[endif\]--> </td> </tr> </table> </body> </html>

HTML tarayıcınızda işlenir, hiçbir yere gönderilmez.

Sonuç 

$@"<!DOCTYPE html> <html lang=""tr"" xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:o=""urn:schemas-microsoft-com:office:office""> <head> <meta charset=""utf-8""> <meta name=""viewport"" content=""width=device-width, initial-scale=1""> <meta name=""color-scheme"" content=""light dark""> <meta name=""supported-color-schemes"" content=""light dark""> <title> Siparişin yolda: #{order.no} </title> <!--\[if mso\]> <xml> <o:OfficeDocumentSettings> <o:PixelsPerInch> 96 </o:PixelsPerInch> </o:OfficeDocumentSettings> </xml> <!\[endif\]--> <style> :root { color-scheme: light dark; supported-color-schemes: light dark; } a { color: #1d5fd6; } @media (max-width: 620px) { .px { padding-left: 22px !important; padding-right: 22px !important; } .col { display: block !important; width: 100% !important; max-width: 100% !important; } .h1 { font-size: 28px !important; line-height: 34px !important; } .hide-sm { display: none !important; } } @media (prefers-color-scheme: dark) { .page { background: #0c111b !important; } .card { background: #151b27 !important; } .ink { color: #edf1f7 !important; } .muted { color: #a8b2c3 !important; } .line { border-color: #2a3243 !important; } .soft { background: #1c2333 !important; } } </style> </head> <body class=""page"" style=""margin:0;padding:0;background:#eef2f8;""> <div style=""display:none;max-height:0;overflow:hidden;mso-hide:all;""> Tahmini teslim {order.eta}.&#8199;&#847;&#8199;&#847;&#8199;&#847;&#8199;&#847;&#8199;&#847; </div> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" class=""page"" style=""background:#eef2f8;""> <tr> <td align=""center"" style=""padding:32px 12px;""> <!--\[if mso\]> <table role=""presentation"" width=""600"" cellpadding=""0"" cellspacing=""0""> <tr> <td> <!\[endif\]--> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""max-width:600px;""> <tr> <td class=""px"" style=""padding:0 8px 18px;""> <table role=""presentation"" cellpadding=""0"" cellspacing=""0""> <tr> <td width=""28"" height=""28"" style=""width:28px;height:28px;background:#1d5fd6;border-radius:8px;font-size:0;line-height:0;""> &nbsp; </td> <td class=""ink"" style=""padding-left:10px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;font-weight:bold;letter-spacing:-0.2px;color:#131a2a;""> {app.name} </td> </tr> </table> </td> </tr> <tr> <td class=""card"" style=""background:#ffffff;border-radius:18px;""> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td class=""px"" style=""padding:36px 44px 12px;""> <h1 class=""h1 ink"" style=""margin:0 0 14px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:32px;line-height:38px;font-weight:bold;letter-spacing:-0.6px;color:#131a2a;""> Siparişin yola çıktı. </h1> <p class=""muted"" style=""margin:0 0 18px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;line-height:25px;color:#4d586b;""> Merhaba {customer.name}, #{order.no} numaralı siparişin kargoya verildi. </p> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""margin:8px 0 26px;""> <tr> <td class=""soft"" style=""padding:22px 24px;background:#eaf1fd;border-radius:14px;""> <p class=""muted"" style=""margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#5d6b85;""> Tahmini teslim </p> <p class=""ink"" style=""margin:0 0 18px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:30px;line-height:36px;font-weight:bold;letter-spacing:-0.5px;color:#131a2a;""> {order.eta} </p> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""margin:0 0 8px;""> <tr> <td width=""25%"" style=""padding:0 4px 0 0;""> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td class="""" style=""height:8px;background:#1d5fd6;border-radius:4px;font-size:0;line-height:0;""> &nbsp; </td> </tr> </table> </td> <td width=""25%"" style=""padding:0 4px 0 0;""> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td class="""" style=""height:8px;background:#1d5fd6;border-radius:4px;font-size:0;line-height:0;""> &nbsp; </td> </tr> </table> </td> <td width=""25%"" style=""padding:0 4px 0 0;""> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td class=""soft"" style=""height:8px;background:#dfe5ee;border-radius:4px;font-size:0;line-height:0;""> &nbsp; </td> </tr> </table> </td> <td width=""25%"" style=""padding:0 0px 0 0;""> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td class=""soft"" style=""height:8px;background:#dfe5ee;border-radius:4px;font-size:0;line-height:0;""> &nbsp; </td> </tr> </table> </td> </tr> <tr> <td valign=""top"" class=""ink"" style=""padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#131a2a;""> Alındı </td> <td valign=""top"" class=""ink"" style=""padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;font-weight:bold;color:#131a2a;""> Kargoda </td> <td valign=""top"" class=""muted"" style=""padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#8a94a6;""> Dağıtımda </td> <td valign=""top"" class=""muted"" style=""padding:8px 4px 0 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:16px;color:#8a94a6;""> Teslim </td> </tr> </table> </td> </tr> </table> <!--\[if mso\]> <table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0""> <tr> <td width=""50%"" valign=""top""> <!\[endif\]--> <div class=""col"" style=""display:inline-block;width:100%;max-width:244px;vertical-align:top;""> <p class=""muted"" style=""margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#7a8597;""> Kargo firması </p> <p class=""ink"" style=""margin:0 0 20px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:15px;font-weight:bold;color:#131a2a;""> {shipping.carrier} </p> </div> <!--\[if mso\]> </td> <td width=""24""> </td> <td width=""50%"" valign=""top""> <!\[endif\]--> <div class=""hide-sm"" style=""display:inline-block;width:24px;font-size:0;""> &nbsp; </div> <div class=""col"" style=""display:inline-block;width:100%;max-width:244px;vertical-align:top;""> <p class=""muted"" style=""margin:0 0 4px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;color:#7a8597;""> Takip numarası </p> <p class=""ink"" style=""margin:0 0 20px;font-family:'Courier New',Courier,monospace;font-size:15px;font-weight:bold;color:#131a2a;""> {shipping.trackingNo} </p> </div> <!--\[if mso\]> </td> </tr> </table> <!\[endif\]--> <table role=""presentation"" cellpadding=""0"" cellspacing=""0"" style=""margin:6px 0 26px;""> <tr> <td> <!--\[if mso\]> <v:roundrect xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:w=""urn:schemas-microsoft-com:office:word"" href=""{order.trackingUrl}"" style=""height:50px;v-text-anchor:middle;width:220px;"" arcsize=""24%"" stroke=""f"" fillcolor=""#1d5fd6""> <w:anchorlock/> <center style=""color:#ffffff;font-family:Arial,sans-serif;font-size:16px;font-weight:bold;""> Kargoyu takip et </center> </v:roundrect> <!\[endif\]--> <!--\[if !mso\]> <!--> <a href=""{order.trackingUrl}"" style=""display:inline-block;background:#1d5fd6;color:#ffffff;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16px;font-weight:bold;line-height:50px;padding:0 30px;border-radius:12px;text-decoration:none;""> Kargoyu takip et </a> <!--<!\[endif\]--> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td class=""px muted"" style=""padding:22px 44px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:12px;line-height:19px;color:#7a8597;""> Bu e-postayı bir sipariş verdiğin için aldın. </td> </tr> </table> <!--\[if mso\]> </td> </tr> </table> <!\[endif\]--> </td> </tr> </table> </body> </html>"

## Neden $@"…"?

Verbatim string ($@) satır sonlarını ve ters eğik çizgileri olduğu gibi tutar, interpolasyon ($) ise {customer.name} gibi değişkenleri C# ifadelerine çevirmenizi sağlar. Bu yüzden HTML'deki çift tırnaklar "" olarak ikilenir; <style> içindeki CSS süslü parantezleri {{ ve }} olarak kaçırılır ki derleyici onları interpolasyon sanmasın.

## Değişkenleri bağlamak

Çıktıdaki {customer.name} gibi yer tutucuları kapsamdaki değişkenlerinizle değiştirin, örneğin {model.CustomerName}. Kullanıcıdan gelen değerleri HTML'e koymadan önce WebUtility.HtmlEncode ile kodlayın.

## Sık sorulan sorular

C# çıktısını tekrar HTML'e çevirebilir miyim?

Evet. Editördeki BE çıktısı paneli düzenlenebilir; yaptığınız değişiklikler HTML'e geri yansır.

Minify etmeli miyim?

Kod okunabilirliği için gerekmez; Gmail'in 102 KB sınırına yaklaşıyorsanız minify edin.
