在Outlook中使用VBA在Web / URL /超链接上保存文件 [英] Using VBA in Outlook to Save File on Web/URL/Hyperlink
本文介绍了在Outlook中使用VBA在Web / URL /超链接上保存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我收到的每周电子邮件始终具有相同的表单,并且具有指向正文中PDF文件的超链接。我知道如何解析电子邮件以检索URL,但是可以让VBA代码从超链接/网址下载该文件并将其保存在文件夹中吗?
So I receive a weekly email that always has the same form and has a hyperlink to a PDF file in the body. I know how to parse the email to retrieve the URL, but is it possible to have VBA code then download that file from the hyperlink/url and save it in a folder?
推荐答案
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub DownloadFile(sURL, sSaveAs)
Dim rv As Long
rv = URLDownloadToFile(0, sURL, sSaveAs, 0, 0)
If rv = 0 Then
MsgBox "Download has been succeed!"
Else
MsgBox "Error"
End If
End Sub
这篇关于在Outlook中使用VBA在Web / URL /超链接上保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文