gpt4 book ai didi

vba - Excel VBA 中的 Outlook 电子邮件和签名 - .Body 与 .HTMLbody

转载 作者:行者123 更新时间:2023-12-04 19:59:56 40 4
gpt4 key购买 nike

我的工作表上有一个按钮来发送电子邮件(还有更多,但不重要)。我想要我的默认签名及其 HTML 格式,但两个选项都没有产生我想要的结果:

  • .Body生成正确的正文(字体和回车),但签名是纯文本
  • .HMTLBody生成正确的签名,但由于某种原因正文,字体转到 Times New Roman 而不是默认的 Calibri,并且无论我使用 vbNewLine,回车都不起作用, vbCr , 或 vbCrLf

  • 我只是S.O.L.吗?我只需要挑选一个并处理它,还是有办法让我有我的蛋糕并吃掉它?

    代码:
        .Display         ' need to display email first for signature to work
    .Subject = Title
    .To = ActiveSheet.Range("E10").Value ' <-- Put email of the recipient here
    .CC = "" ' <-- Put email of 'copy to' recipient here
    .HTMLBody = "Thank you for the opportunity to bid on " & ActiveSheet.Range("B9").Value & ". " & _
    " Please read our attached proposal in its entirety to be sure of all inclusions, exclusions, and products proposed. Give us a call with any questions or concerns." & _
    vbCrLf & vbCrLf & _
    "Thank you," & _
    .HTMLBody ' Adds default signature
    .Attachments.Add PdfFile

    更新:

    得益于以下两个答案的帮助,最终的工作代码:
    .Display         ' We need to display email first for signature to be added
    .Subject = Title
    .To = ActiveSheet.Range("E10").Value
    .CC = ""
    .HTMLBody = "<font face=""calibri"" style=""font-size:11pt;"">Thank you for the opportunity to bid on " & ActiveSheet.Range("B9").Value & ". " & " Please read our attached proposal in its entirety to be sure of all inclusions, exclusions, and products proposed. Give us a call with any questions or concerns." & _
    "<br><br>" & _
    "Thank you," & _
    .HTMLBody & "</font>" ' Adds default signature
    .Attachments.Add PdfFile

    最佳答案

    设置 HTMLBody 属性时,确保合并现有的 HTMLBody (带有签名)和您的新数据 - 您不能仅仅连接两个 HTML 字符串并期望一个有效的 HTML。
    找到 "<body" 的位置字符串,找到下一个“>”的位置(以处理带有属性的主体元素),在“>”之后插入数据。

    关于vba - Excel VBA 中的 Outlook 电子邮件和签名 - .Body 与 .HTMLbody,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36211195/

    40 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com