目前我已经创建了一个宏,其中有一些内容为Body,之后我想显示outlook用户的默认签名。
我在excel中有两个按钮,每个按钮有两个宏按钮。
。显示我认为负责签名显示,但是当我使用它时,Signature不是第一个宏而是第二个功能它即将到来但是
身体的顶部也。 请告知该怎么做。 以下是我的宏: -
Sub email()
Dim OlApp As Object
Set OlApp = CreateObject("Outlook.Application")
Dim myNameSp As Object
'Set myNameSp = CreateObject("Outlook.Namespace")
Dim myInbox As Object
'Set myInbox = CreateObject("Outlook.MAPIFolder")
Dim myExplorer As Object
'Set myExplorer = CreateObject("Outlook.Explore")
Dim NewMail As Object
'Set NewMail = CreateObject("Outlook.MailItem")
Dim OutOpen As Boolean
Dim nameList As String
Dim lastRow As Integer
Dim CCLISt As String
Dim Result As Integer
Dim ResultTo As Integer
Dim ResultCC As Integer
Dim CCLISTAppned As String
'count last working row
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim i As Integer
For i = 11 To lastRow 'use cells 7 to 39 in column "I" where names are stored
If Sheets("Sheet1").Range("A" & i).Value = "Y" Then
If Sheets("Sheet1").Range("H" & i).Value <> "" Then
ResultTo = InStr(nameList, Sheets("Sheet1").Range("H" & i).Value)
If (ResultTo = 0) Then
nameList = nameList & ";" & Sheets("Sheet1").Range("H" & i).Value
End If
Result = InStr(CCLISt, Sheets("Sheet1").Range("L" & i).Value)
If (Result = 0) Then
CCLISt = CCLISt & ";" & Sheets("Sheet1").Range("L" & i).Value
End If
ResultCC = InStr(CCLISTAppned, Sheets("Sheet1").Range("N" & i).Value)
If (ResultCC = 0) Then
CCLISTAppned = CCLISTAppned & ";" & Sheets("Sheet1").Range("N" & i).Value
End If
End If
End If
Next
CCLISt = CCLISt & CCLISTAppned
' Check to see if there's an explorer window open
' If not then open up a new one
OutOpen = True
Set myExplorer = OlApp.ActiveExplorer
If TypeName(myExplorer) = "Nothing" Then
OutOpen = False
Set myNameSp = OlApp.GetNamespace("MAPI")
'Set myInbox = myNameSp.GetDefaultFolder(olFolderInbox)
' Set myExplorer = myInbox.GetExplorer
End If
' If you don't to display your outlook while sending email then comment the below statement
'otherwise you can un-comment
'myExplorer.Display
' Create a new mail message item.
Set NewMail = OlApp.CreateItem(0)
With NewMail
'.Display ' You don't have to show the e-mail to send it
.Display
.Subject = "Audit Response Requested - ["
.Subject = .Subject & Sheets("Sheet1").Range("E2").Value & "/"
.Subject = .Subject & Sheets("Sheet1").Range("E1").Value & "]"
.To = nameList
.CC = CCLISt
.HTMLBody = "<b><h2 style=color:blue; background-color:yellow><p style=background: yellow><center>Please use voting buttons above to facilitate your reply. </center></p></h2></b>"
.HTMLBody = .HTMLBody & "We have been asked by <b>" & Sheets("Sheet1").Range("E2").Value & "</b>, to furnish information in conjunction with their annual financial audit. "
.HTMLBody = .HTMLBody & "According to the Firm's records, you have recorded time on matters for the Company [<b> [and/or its subsidiaries]</b> since their last annual audit. "
.HTMLBody = .HTMLBody & "[<b> Our last letter (and its Exhibit A) is printed out below. </b>] Accordingly, please respond as to "
.HTMLBody = .HTMLBody & "whether or not you have anything material to report. " & "<b>[Please send [email sender] if you have questions about any materiality thresholds.] [Our response is due [date]].</b>" & " Thank you!"
.HTMLBody = .HTMLBody & "<br><br>" & "For your information:" & "<br><br>"
.HTMLBody = .HTMLBody & "1. Are you aware of any (1) pending litigation, or (2) overtly threatened litigation, meaning that a potential claimant has manifested to the Company an awareness of and present intention to assert a possible claim or assessment?"
.HTMLBody = .HTMLBody & "<br>" & "2. Are you aware of or have you worked on any matter for the Company which may involve an unasserted possible claim or assessment that may call for financial statement disclosure? Financial statement disclosure of material unasserted claims or assessments may be required in the following cases:"
.HTMLBody = .HTMLBody & "<br>" & "  (a) where there has been a manifestation by a potential claimant of an awareness of a possible claim or assessment and there is a reasonable possibility that the outcome will be unfavorable, or "
.HTMLBody = .HTMLBody & "<br>" & "  (b) where there has been no manifestation by a potential claimant of an awareness of a possible claim or assessment but it is considered probable that a claim will be asserted and there is a reasonable possibility that the outcome will be unfavorable. Examples of this include the following: "
.HTMLBody = .HTMLBody & "<br>" & "   (i) a catastrophe, accident, or other similar physical occurrence in which the client's involvement is open and notorious, or"
.HTMLBody = .HTMLBody & "<br>" & "  (ii) an investigation by a government agency where enforcement proceedings have been instituted or where the likelihood that they will not be instituted is remote, under circumstances where assertion of one or more private claims for redress would normally be expected, or"
.HTMLBody = .HTMLBody & "<br>" & "  (iii) a public disclosure by the client acknowledging (and thus focusing attention upon) the existence of one or more probable claims arising out of an event or circumstance"
.HTMLBody = .HTMLBody & "<br>" & "3. Have you during the period in question called to the client's attention any matters you thought the client should consider for financial statement disclosure? <b/>"
.HTMLBody = .HTMLBody & "<br>" & "<b>[4. Are you aware of any material litigation, claims or assessments relating to the Company that have been settled?]"
.HTMLBody = .HTMLBody & "<br>" & "<b>=============================<b/>" & "<br>" & "<b>Last [Annual] Audit Letter dated [***]<b/>"
.VotingOptions = "NOTHING TO REPORT;Yes - Please choose edit to explain in email Reply;"
End With
'NewMail.Send
'If Not OutOpen Then OlApp.Quit
'Release memory.
Set OlApp = Nothing
Set myNameSp = Nothing
Set myInbox = Nothing
Set myExplorer = Nothing
Set NewMail = Nothing
End Sub
Sub Reminder()
Dim OlApp As Object
Set OlApp = CreateObject("Outlook.Application")
Dim myNameSp As Object
'Set myNameSp = CreateObject("Outlook.Namespace")
Dim myInbox As Object
'Set myInbox = CreateObject("Outlook.MAPIFolder")
Dim myExplorer As Object
'Set myExplorer = CreateObject("Outlook.Explore")
Dim NewMail As Object
'Set NewMail = CreateObject("Outlook.MailItem")
Dim OutOpen As Boolean
Dim nameList As String
Dim lastRow As Integer
Dim CCLISt As String
Dim Result As Integer
Dim ResultTo As Integer
Dim ResultCC As Integer
Dim CCLISTAppned As String
'count last working row
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim i As Integer
For i = 11 To lastRow 'use cells 7 to 39 in column "I" where names are stored
If Sheets("Sheet1").Range("B" & i).Value = "" And Sheets("Sheet1").Range("A" & i).Value = "Y" Then
If Sheets("Sheet1").Range("H" & i).Value <> "" Then
ResultTo = InStr(nameList, Sheets("Sheet1").Range("H" & i).Value)
If (ResultTo = 0) Then
nameList = nameList & ";" & Sheets("Sheet1").Range("H" & i).Value
End If
Result = InStr(CCLISt, Sheets("Sheet1").Range("L" & i).Value)
If (Result = 0) Then
CCLISt = CCLISt & ";" & Sheets("Sheet1").Range("L" & i).Value
End If
ResultCC = InStr(CCLISTAppned, Sheets("Sheet1").Range("N" & i).Value)
If (ResultCC = 0) Then
CCLISTAppned = CCLISTAppned & ";" & Sheets("Sheet1").Range("N" & i).Value
End If
End If
End If
Next
CCLISt = CCLISt & CCLISTAppned
' Check to see if there's an explorer window open
' If not then open up a new one
OutOpen = True
Set myExplorer = OlApp.ActiveExplorer
If TypeName(myExplorer) = "Nothing" Then
OutOpen = False
Set myNameSp = OlApp.GetNamespace("MAPI")
' Set myInbox = myNameSp.GetDefaultFolder(olFolderInbox)
'Set myExplorer = myInbox.GetExplorer
End If
' If you don't to display your outlook while sending email then comment the below statement
'otherwise you can un-comment
'myExplorer.Display
' Create a new mail message item.
Set NewMail = OlApp.CreateItem(0)
With NewMail
'.Display ' You don't have to show the e-mail to send it
.Subject = "Audit Response Requested - ["
.Subject = .Subject & Sheets("Sheet1").Range("E2").Value & "/"
.Subject = .Subject & Sheets("Sheet1").Range("E1").Value & "]"
.To = nameList
.CC = CCLISt
.HTMLBody = .HTMLBody & "This is a quick reminder that our response for " & Sheets("Sheet1").Range("E2").Value & " is due. Please respond to below as soon as you are able. Thanks!"
.HTMLBody = .HTMLBody & "<b><h2 style=color:blue background: #FFFF00><p style=background: yellow><center>Please use voting buttons above to facilitate your reply. </center></p></h2></b>"
.HTMLBody = .HTMLBody & "We have been asked by <b>" & Sheets("Sheet1").Range("E2").Value & "</b>, to furnish information in conjunction with their annual financial audit. "
.HTMLBody = .HTMLBody & "According to the Firm's records, you have recorded time on matters for the Company [<b> [and/or its subsidiaries]</b> since their last annual audit. "
.HTMLBody = .HTMLBody & "[<b> Our last letter (and its Exhibit A) is printed out below. </b>] Accordingly, please respond as to "
.HTMLBody = .HTMLBody & "whether or not you have anything material to report. " & "<b>[Please send [email sender] if you have questions about any materiality thresholds.] [Our response is due [date]].</b>" & "Thank you!"
.HTMLBody = .HTMLBody & "<br><br>" & "For your information:" & "<br><br>"
.HTMLBody = .HTMLBody & "1. Are you aware of any (1) pending litigation, or (2) overtly threatened litigation, meaning that a potential claimant has manifested to the Company an awareness of and present intention to assert a possible claim or assessment?"
.HTMLBody = .HTMLBody & "<br>" & "2. Are you aware of or have you worked on any matter for the Company which may involve an unasserted possible claim or assessment that may call for financial statement disclosure? Financial statement disclosure of material unasserted claims or assessments may be required in the following cases:"
.HTMLBody = .HTMLBody & "<br>" & "  (a) where there has been a manifestation by a potential claimant of an awareness of a possible claim or assessment and there is a reasonable possibility that the outcome will be unfavorable, or "
.HTMLBody = .HTMLBody & "<br>" & "  (b) where there has been no manifestation by a potential claimant of an awareness of a possible claim or assessment but it is considered probable that a claim will be asserted and there is a reasonable possibility that the outcome will be unfavorable. Examples of this include the following: "
.HTMLBody = .HTMLBody & "<br>" & "   (i) a catastrophe, accident, or other similar physical occurrence in which the client's involvement is open and notorious, or"
.HTMLBody = .HTMLBody & "<br>" & "  (ii) an investigation by a government agency where enforcement proceedings have been instituted or where the likelihood that they will not be instituted is remote, under circumstances where assertion of one or more private claims for redress would normally be expected, or"
.HTMLBody = .HTMLBody & "<br>" & "  (iii) a public disclosure by the client acknowledging (and thus focusing attention upon) the existence of one or more probable claims arising out of an event or circumstance"
.HTMLBody = .HTMLBody & "<br>" & "3. Have you during the period in question called to the client's attention any matters you thought the client should consider for financial statement disclosure? <b/>"
.HTMLBody = .HTMLBody & "<br>" & "<b>[4. Are you aware of any material litigation, claims or assessments relating to the Company that have been settled?]"
.HTMLBody = .HTMLBody & "<br>" & "<b>=============================<b/>" & "<br>" & "<b>Last [Annual] Audit Letter dated [***]<b/>"
.Display
.VotingOptions = "NOTHING TO REPORT;Yes - Please choose edit to explain in email Reply;"
End With
'NewMail.Send
'If Not OutOpen Then OlApp.Quit
'Release memory.
Set OlApp = Nothing
Set myNameSp = Nothing
Set myInbox = Nothing
Set myExplorer = Nothing
Set NewMail = Nothing
End Sub
答案 0 :(得分:0)
尝试在Set NewMail = OlApp.CreateItem(0)
' Create a new mail message item.
Dim Signature As String
Set NewMail = olApp.CreateItem(0)
Signature = NewMail.HTMLBody
With NewMail
'.Display ' You don't have to show the e-mail to send it
.Display
.Subject = "Audit Response Requested - ["
.HTMLBody = .HTMLBody & vbNewLine & Signature
.To = nameList
.CC = CCLISt
答案 1 :(得分:0)
Outlook对象模型不为签名提供任何方式。但您可以使用VBA宏在运行时编辑消息正文。
Outlook对象模型为工作项主体提供了三种主要方式:
您可以在Chapter 17: Working with Item Bodies中详细了解所有这些方式。我们取决于您选择在邮件正文中自定义签名。
请注意,当您使用HTMLBody
属性时,需要在结束</body>
标记之前添加签名内容(格式良好的HTML标记),而不仅仅是附加HTMLBody字符串。因此,在HTMLBody字符串中找到结束体标记并在那里插入您的签名。
答案 2 :(得分:0)
这显示了如何使用Omar答案中使用的方法获得签名。
Sub email_Signature_Demo()
' Run this demo code in Outlook
With CreateItem(0)
MsgBox ".HTMLBody is not the signature." & vbCr & vbCr & .HTMLBody
.Display ' This is required at the start, not the end
MsgBox ".HTMLBody is the signature " & vbCr & vbCr & .HTMLBody
.HTMLBody = "According to the Firm's records... " & .HTMLBody
End With
End Sub