excel - VBA 文件目录链接到 Outlook
问题描述
我编写了以下代码(基于 SO 中的其他帖子)以将超链接插入到工作簿保存在网络驱动器上的文件夹到电子邮件正文中,并且链接不会显示在正文中电子邮件,我不知道为什么。任何帮助是极大的赞赏。
我确实在参考中检查了 Microsoft Outlook 对象库。
我已经尝试过hyperlink = "<a href=""" & currDir & """></a>"
,hyperlink = "<a href=" & currDir & "></a>"
但无济于事。
以下是完整代码:
Private Sub FileToApprRev_Click()
Dim OutlookApp As Object, MItem As Object
Dim Subj As String, EmailAddr As String, Recipient As String
Dim LienPos As Range, clsDate As Range, address As String, lNum As Range, Street As Range, City As Range, State As Range, ZipCode As Range, CustName As Range
Dim strBody As String, Email As String, hyperlink As String, currDir As String
Set wb = Application.ThisWorkbook
Set wsSI = wb.Sheets("SavedInfo")
Set Street = wsSI.Range("Street")
Set City = wsSI.Range("City")
Set State = wsSI.Range("State")
Set ZipCode = wsSI.Range("Zip")
Set lNum = wsSI.Range("Loan_Number")
Set clsDate = wsSI.Range("Closing_Date")
Set LienPos = wsSI.Range("Lien_Position")
Set CustName = wsSI.Range("PBName")
address = Street & ", " & City & ", " & State & " " & ZipCode
Set OutlookApp = CreateObject("Outlook.Application")
Set MItem = OutlookApp.CreateItem(0)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Email = "SpongeBob@UnderTheSeaHeaven.com"
currDir = wb.path
hyperlink = "<a href=""" & currDir & """></a>"
Debug.Print hyperlink
strBody = "<p>" & "Hello , " & "<br><br>" & vbNewLine & vbNewLine & _
"Please complete the Appraisal Review for the file below." & "</p>" & vbNewLine & _
hyperlink
With MItem
.Display
.to = Email
.Subject = "ATTN - Appraisal Review" & " - " & CustName & " - " & clsDate
.HTMLBody = strBody & "<br>" & .HTMLBody
.send
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
解决方案
我想到了。我为文件目录使用了不正确的结构。
target = "\\fsps02\users\......"
推荐阅读
- oracle - 在项目上分配数量
- javascript - 如何从散点图中选择一个点并显示有关它的数据?
- mysql - 防止 INSERT INTO ... SELECT 语句创建自己的新快照
- angular - 简短的 TypeScript 导入语句语法在 Angular 中不起作用
- angular - cropper.replace 不替换图像
- windows - 使用 PowerShell 远程编辑注册表项的问题
- python - LSTM 的时间序列分类中的损失和准确率保持不变
- apache - 如何将子域重定向到根域?
- odata - 如何在 SET_GET_ENTITY 方法中为“数量”类型的字段编写 SELECT?
- sql - 是否可以在 WHERE 子句中使用 IF 语句并根据不同的 IF 值使用 INTO 语句?