开发者

Align Outlook htmlbody right to left

How do I align a HTMLBody in Outlook to be right to left?

Here's my code for sending the message (the body is in a textbox)

       private void sendmail()
       {
       outlook.Application outApp;
       outApp = new outlook.Application();
       outlook.MailItem mail = (outlook.MailItem)(outApp.CreateItem         
       (outlook.OlItemType.olMailItem));
       mail.BodyFormat = outlook.OlBodyFormat.olFormatHTML;
       mail.To = textTo.开发者_StackOverflowText;
       mail.CC = textCC.Text;
       mail.Subject = textSubject.Text;
       mail.HTMLBody = textBody.Text; 
       }


if by right to left align you mean RTL scripts use this

 mail.HTMLBody = "<p DIR=\"RTL\">" + textBody.Text + "</p>";

if you just want the text to be aligned either left or right use this snippet:

mail.HTMLBody = "<p style=\"text-align:left;\">"  + textBody.Text + "</p>";//aligned left


Try wrapping your textBody.Text string in the following HTML

<table width='100%'><tr><td align="right">[YOUR TEXTBODY.TEXT VAR GOES HERE]</td></tr></table>

e.g.

mail.HTMLBody = "<table width='100%'><tr><td align="right">"+textBody.Text+"</td></tr></table>";

or if you wanted your body content to be a certain width

mail.HTMLBody = "<table width='600'><tr><td align="right">"+textBody.Text+"</td></tr></table>";

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜