我在Excel中創建了一個宏,每次更新特定文件時都會向各種用戶發送電子郵件。如何將超鏈接插入電子郵件正文
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim answer As String
answer = MsgBox("Would you like to save the changes?", vbYesNo, "Save Document")
If answer = vbNo Then Cancel = True
If answer = vbYes Then
'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
'add recipients
'newmsg.Recipients.Add ("Name1")
newmsg.Recipients.Add ("[email protected]")
'newmsg.Recipients.Add ("Name2")
newmsg.Recipients.Add ("[email protected]")
'add subject
newmsg.Subject = "Notification - Update file"
'add body
newmsg.Body = "This is an automated notification." & vbNewLine & vbNewLine & _
"The XXX file has been recently updated" & vbNewLine & vbNewLine & _
"Please do not reply to this email."
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "Your document has successfully been saved", , "Confirmation"
End If
'save the document
'Me.Worksheets.Save
End Sub
我想超鏈接添加到正文它說:「該XXX文件最近已經更新」,使XXX文件是一個可點擊的鏈接到一個網站。
感謝您的詳細解釋,尤金。我只是開始使用vba代碼,所以總是很好的理解這些邏輯。 – IdCB