gpt4 book ai didi

excel - 如何在 Excel VBA 电子邮件中添加签名?

转载 作者:行者123 更新时间:2023-12-04 21:16:37 25 4
gpt4 key购买 nike

当用户连续单击一个单元格时,我使用此 VBA 代码发送电子邮件。

我想在我的电子邮件正文中添加带有图像的签名。我怎么能修改我的代码来把它放进去?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Column = Range("BL1").Column Then

If Target.Row > 7 And Target.Value = "Take Action" Then

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "<p style='font-family:calibri;font-size:16'>" & "Dear Sirs," & "<br><br>" & vbNewLine & vbNewLine & _
"F.A.O: " & "<b>" & Range("B" & ActiveCell.Row) & "</b>" & "," & vbNewLine & vbNewLine & _
"<br>" & "This is an urgent update on the status of your account." & "<br>" & vbNewLine & _
"Our records show that your insurance is due to expire on: " & "<b>" & Format(Range("BE" & ActiveCell.Row), "dd" & " Mmmm " & "yyyy") & "." & "</b>" & " To ensure that you remain active on our systems as an approved Hewden Stuart Ltd Supplier, it is important that you provide us with the details of your renewed insurance policy. Please can you provide us with these details for the following insurance as soon as possible, in order to remain active on our systems:" & vbNewLine & vbNewLine & _
"<br><br>" & "Insurance: " & "<b>" & "{Insurance Type Goes Here}" & "</b>" & "<br>" & vbNewLine & _
"Due for Period: " & "<b>" & Format(Range("BE" & ActiveCell.Row), "dd" & " Mmmm " & "yyyy") & "</b>" & " - " & "<b>" & Format(Range("BE" & ActiveCell.Row) + 365, "dd" & " Mmmm " & "yyyy") & "</b>" & vbNewLine & vbNewLine & _
"<br><br>" & "Note:" & "<br>" & vbNewLine & _
"Please ensure that the above information is provided by your insurance broker, or your insurer, in the form of a standard letter or certificate. If your insurance is in the name of a parent company, please provide a breakdown of the companies covered from your insurer. In order to provide us with the above information, please login to your Control Panel with your unique Username and Password and attach your documents. Regrettably, failure to provide us with the information requested will result in suspension of your account. If you have any queries, please email us at SupplierAudits@Hewden.co.uk." & vbNewLine & vbNewLine & _
"<br><br>" & "Your Reference:" & "<br><br>" & vbNewLine & vbNewLine & _
"<b>" & Range("AB" & ActiveCell.Row) & "</b>" & vbNewLine & _
"<p style='font-family:calibri;font-size:13'>" & "Please quote your unique Supplier Reference number when providing us with any insurance documents and in the even that you should have any enquiries." & "</p>" & vbNewLine & vbNewLine & _
"<p style='font-family:calibri;font-size:16'>" & "<br>" & "Kind Regards," & "<br><br>" & vbNewLine & vbNewLine & _
"<b>" & "Hewden Supply Chain Department" & "</b>" & "</P>"

With OutMail
.SentOnBehalfOfName = "newsuppliers@hewden.co.uk"
.To = "mark.o'brien@hewden.co.uk"
.CC = ""
.BCC = ""
.Subject = "Important! - Insurance Alert!"
.HTMLbody = strbody
.Attachments.Add ("P:\cover.jpg")
.Send 'or use .Display
End With

End If

End If

End Sub

最佳答案

当您调用 MailItem.Display 时,Outlook 会将签名添加到新的未修改邮件(您不应在此之前修改正文)。 (这会导致消息显示在屏幕上)或当您访问 MailItem.GetInspector 时属性 - 您不必对返回的 Inspector 对象执行任何操作,但 Outlook 将使用签名填充邮件正文。
添加签名后,请阅读 HTMLBody属性并将其与您尝试设置的 HTML 字符串合并。请注意,您不能简单地连接 2 个 HTML 字符串 - 这些字符串需要合并。例如。如果您想在 HTML 正文的顶部插入字符串,请查找 <body子字符串,然后找到下一个出现的 > (这会处理带有属性的 <body> 元素),然后在 > 之后插入您的 HTML 字符串.嵌入的图像附件和样式必须分开处理。
一般而言,签名的名称存储在可通过 IOlkAccountManager 访问的帐户配置文件数据中。扩展的 MAPI 接口(interface)。由于该接口(interface)是扩展 MAPI,因此只能使用 C++ 或 Delphi 访问它。您可以在 OutlookSpy 中查看接口(interface)及其数据(我是它的作者)如果你点击IOlkAccountManager按钮。
Outlook 对象模型不公开签名或访问帐户的任意属性。
如果使用 Redemption是一个选项(我也是它的作者),你可以使用它的RDOAccount对象(可以任何语言访问,包括 VBA)。新消息签名名称存储在 0x0016001F 属性中,回复签名在 0x0017001F 中。您也可以使用 RDOAccount . ReplySignatureNewSignature特性。
所有 Outlook 签名都通过 RDOSession.Signatures 公开。收藏。
可以使用 RDOSignature.ApplyTo 将签名应用于消息。 - 它将负责正确合并数据并引入嵌入式图像附件和样式。
编辑 :截至 2017 年夏季,仅 MailItem.Display在 Outlook 2016 中插入签名。MailItem.GetInspector不再这样做了。

关于excel - 如何在 Excel VBA 电子邮件中添加签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25571411/

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