我正在尝试从Outlook邮件中收到的超链接框中下载文件。
我想在最新收到的邮件中查找链接,并将此文件保存在特定路径上。
如何打开超链接并下载单击后提示下载的文件?
到目前为止,这是我的代码:
Sub SaveOlLink()
Dim OutApp As Object
Dim olFolder As Outlook.MAPIFolder
Dim msg, oDoc, h As Object
Dim fsSaveFolder, sSavePathFS, ssender As String
Dim SidstModt As Date
Set OutApp = CreateObject("Outlook.Application")
'setting savepath
fsSaveFolder = "savepath"
'setting mailbox and mailfolder to look in
Set olFolder = Outlook.GetNamespace("MAPI").Folders("mailbox")
Set olFolder = olFolder.Folders("mailfolder")
' if monday use file from saturday
' if any other day than monday use the file received on the day
If Weekday(Now(), vbMonday) = 1 Then
SidstModt = [today()] - 2
Else: SidstModt = [today()]
End If
'loop through mails,
' find mail with specified subject and date and click the link in this
For Each msg In olFolder.Items
If msg.Subject = "mail subject" And msg.SentOn >= SidstModt Then
'here i would like to write the code that opens only a specific
' hyperlink in the mail and saves the file that is asked to be downloaded
'define the savepath
'sSavePathFS = fsSaveFolder & "filename"
'MsgBox "File is saves as" & sSavePathFS
Exit Sub
End If
Next
MsgBox "Mail not found"
End Sub