简体   繁体   English

如何在VB.net中更改字体大小

[英]How to change font size in VB.net

I want to below script to send an email to lotus notes, but I find that in lotus notes, the font size of body message is a little bigger, so I want to change its font size to a small one, but due to string body in below function is a variable, I don't know how to change its font size, so could anyone here can help me ? 我想在下面的脚本中向Lotus Notes发送电子邮件,但是我发现在Lotus Notes中,主体消息的字体大小稍大,因此我想将其字体大小更改为较小,但是由于字符串主体在下面的函数中是一个变量,我不知道如何更改其字体大小,所以这里有人可以帮助我吗? thanks in advance 提前致谢

    Public Shared Sub SendMail(ByVal from As String, ByVal towhere As String, ByVal subject As String, ByVal body As String)
    Dim mailservername As String
    mailservername = "POSTMASTER@mailserver.com"

    Dim Message As New System.Net.Mail.MailMessage(from, towhere, subject, body)

    Dim mailClient As New System.Net.Mail.SmtpClient()
    mailClient.Host = mailservername
    mailClient.UseDefaultCredentials = True
    mailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
    mailClient.Send(Message)
    End Sub

   the body message is such as body = str1 + " " + str2 + " " + str3
   str1 and str2 are constant strings, but str3 are variable, what I want to change is str3's font size

The mail body can be in different formats. 邮件正文可以采用不同的格式。 What your using above is pain text format (content type is text/plain). 您在上面使用的是痛苦的文本格式(内容类型为text / plain)。 You can use html format (text/html) along with (or instead of) text format, then in html, you can style your mail richly using CSS styles or html tags. 您可以将html格式(text / html)与文本格式一起使用(或代替文本格式),然后在html中,可以使用CSS样式或html标签来丰富邮件的样式。 See this article that introduce how to send an html mail. 请参阅本文介绍如何发送html邮件。

Edit : Edited to put code fragment (in comment, it becomes messy) 编辑 :编辑以放置代码片段(在注释中,它变得凌乱)

body = "<span style=""font-size:10pt;"">" + str1 + " " + str2 + "</span><span style=""font-size:12pt;"">" + str3 + "</span>"
mailClient.Body = body
mailClient.IsBodyHtml = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM