Outlook从超链接下载文件 [英] Outlook Download Files from Hyperlink

查看:157
本文介绍了Outlook从超链接下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求一些帮助,以使每天执行几次的任务自动化.

我收到来自某个地址的电子邮件,然后将其自动排序(使用规则")到专用文件夹中.

这些电子邮件包含指向要从Web下载的文档的超链接;但是,这些链接不是作为URL编写的,而是有一个链接显示为下载所有文档".

我单击此链接,它将打开URL,该URL是所有文档的zip文件.然后,我将该zip文件以某种命名格式保存到某个文件夹中.

我正在寻求使这一过程自动化.手动完成这项任务很麻烦,因为我收到了很多这样的电子邮件,并且由于默认名称包含非法字符,因此重命名它们需要时间.

我之前已经做过一些编程,但是在VBA(Excel)中只有一点点,对于Outlook从来没有.

我已经在论坛中搜索了类似的问题,看来我可以使用URLDownloadToFile函数(例如解决方案

URL在超链接中. https://msdn.microsoft.com/en -us/library/microsoft.office.interop.word.hyperlink_members.aspx

Sub HyperlinkAddress()

Dim msg As Object
Dim oDoc As Object
Dim h As Object

Set msg = ActiveInspector.currentItem

If msg.GetInspector.EditorType = olEditorWord Then

    Set oDoc = msg.GetInspector.WordEditor

    For Each h In oDoc.Hyperlinks
        Debug.Print "Displayed text: " & h.TextToDisplay & vbCr & " - Address: " & h.Address
        'h.Follow
    Next

End If

Set msg = Nothing
Set oDoc = Nothing
Set h = Nothing

End Sub

I'm looking for some assistance with automating a task I do several times per day.

I receive emails from a certain address which I automatically sort (using Rules) into a dedicated folder.

These emails contain hyperlinks to documents to download from the web; however the links are not written as a URL, rather there is a link saying "Download all Documents".

I click on this link, it opens the URL which is a zip file of all the documents. I then save this zip file in a certain naming format into a certain folder.

I'm looking to automate this process. It's a fiddly task doing it manually because I receive many such emails, and renaming them takes time because the default name contains illegal characters.

I've done some programming before, but only a little bit in VBA (Excel) and never for Outlook.

I've searched through the forums for similar questions, and it appears I can use the URLDownloadToFile function (e.g. UrlDownloadToFile in Access 2010 - Sub or Function not Defined); however I need to pass a URL to that function, and I don't know how to get that out of the email since it's not contained within the body of the email.

Can anyone help me here?

解决方案

The URL is in the hyperlink. https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members.aspx

Sub HyperlinkAddress()

Dim msg As Object
Dim oDoc As Object
Dim h As Object

Set msg = ActiveInspector.currentItem

If msg.GetInspector.EditorType = olEditorWord Then

    Set oDoc = msg.GetInspector.WordEditor

    For Each h In oDoc.Hyperlinks
        Debug.Print "Displayed text: " & h.TextToDisplay & vbCr & " - Address: " & h.Address
        'h.Follow
    Next

End If

Set msg = Nothing
Set oDoc = Nothing
Set h = Nothing

End Sub

这篇关于Outlook从超链接下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆