下面被張貼HK1響應答案在VBA發送電子郵件沒有Outlook的代碼的電子郵件簽名,日期爲7月20日12包括在
代碼工作很好,但我需要添加一個簽名塊在文本的末尾(基本上是一個本地文件夾中的jpg文件),但是我能夠想到的最好的方式是將路徑(文本)而不是圖像本身添加到電子郵件正文。
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
' Use basic (clear-text) authentication.
Const cdoBasic = 1
' Use NTLM authentication
Const cdoNTLM = 2 'NTLM
Public Sub SendEmail()
Dim imsg As Object
Dim iconf As Object
Dim flds As Object
Dim schema As String
Set imsg = CreateObject("CDO.Message")
Set iconf = CreateObject("CDO.Configuration")
Set flds = iconf.Fields
' send one copy with SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
flds.Item(schema & "sendusing") = cdoSendUsingPort
flds.Item(schema & "smtpserver") = "mail.myserver.com"
flds.Item(schema & "smtpserverport") = 25
flds.Item(schema & "smtpauthenticate") = cdoBasic
flds.Item(schema & "sendusername") = "[email protected]"
flds.Item(schema & "sendpassword") = "password"
flds.Item(schema & "smtpusessl") = False
flds.Update
With imsg
.To = "[email protected]"
.From = "[email protected]"
.Subject = "Test Send"
.HTMLBody = "Test"
'.Sender = "Sender"
'.Organization = "My Company"
'.ReplyTo = "[email protected]"
Set .Configuration = iconf
.Send
End With
Set iconf = Nothing
Set imsg = Nothing
Set flds = Nothing
End Sub
我試圖修改代碼如下,但這只是添加文件路徑正文:
With imsg
.To = vRecipients
.From = senderEmail
.CC = vCC
.Subject = vSubject
vBody = Replace(vBody, vbCrLf, "<br>")
vBody = "<FONT face=arial size=2>" & vBody
vBody = vBody & "<br>" & signFile
.HTMLBody = vBody
.Sender = senderName
.ReplyTo = senderEmail
.AddAttachment vAttachments
Set .Configuration = iconf
.Send
End With
有什麼建議?
所以'signFile'只包含簽名文件的文件名。然後你必須閱讀文件的內容並將其添加到正文中。 – dwo