我在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