VBA脚本自动对电子邮件中的第一个超链接进行操作 [英] VBA script to automatically action the first hyperlink in an email
问题描述
我被给了这个,但它只打开电子邮件中的URL,但不是第一个超链接
Sub LaunchURL(itm As MailItem)
Dim bodyString As String
Dim bodyStringSplitLine
Dim bodyStringSplitWord
Dim splitLine
Dim splitWord
bodyString = itm.Body
bodyStringSplitLine = Split(bodyString,vbCrLf)
对于每个splitLine在bodyStringSplitLine
bodyStringSplitWord = Split split line)
对于每个splitWord在bodyStringSplitWord
如果Left(splitWord,7)=http://然后
Shell(C:\Program Files \Internet Explorer\IEXPLORE.EXE&& splitWord)
结束如果
下一个
下一个
设置itm = Nothing
End Sub
私有子测试()
Dim currItem As MailItem
设置currItem = ActiveInspector.cu rrentItem
LaunchURL currItem
End Sub
p> LaunchURL代码专门用于URL可见的位置,如
VBA脚本,用于在Web浏览器中为邮件正文自动打开URL,用于所有传入的邮件,例如它以纯文本邮件。
链接隐藏在哪里,您可以选择文本,将其转到Word,其中有 Hyperlink.Follow方法
编辑:找到更简单不去Word。
Public Sub FollowLinkAddress(itm As Outlook.MailItem)
Dim oDoc As Object
Dim h
设置itm = ActiveInspector.CurrentItem
如果itm.GetInspector.EditorType = olEditorWord然后
设置oDoc = itm.GetInspector.WordEditor
对于每个h在oDoc.Hyperlinks
h
如果
End Sub
I am very new to this so please be gentle. I am using outlook 2010 and I need a vba script to automatically locate and action the first hyperlink in an email. I can use the outlook mailbox rules to select this script but I cannot write it. Any help will be appreciated
I was given this but it only opens URL's in the email but not the first hyperlink
Sub LaunchURL(itm As MailItem)
Dim bodyString As String
Dim bodyStringSplitLine
Dim bodyStringSplitWord
Dim splitLine
Dim splitWord
bodyString = itm.Body
bodyStringSplitLine = Split(bodyString, vbCrLf)
For Each splitLine In bodyStringSplitLine
bodyStringSplitWord = Split(splitLine, " ")
For Each splitWord In bodyStringSplitWord
If Left(splitWord, 7) = "http://" Then
Shell ("C:\Program Files\Internet Explorer\IEXPLORE.EXE" & " " & splitWord)
End If
Next
Next
Set itm = Nothing
End Sub
Private Sub test()
Dim currItem As MailItem
Set currItem = ActiveInspector.currentItem
LaunchURL currItem
End Sub
The LaunchURL code is specifically for use where the URL is visible, like this VBA script for outlook to automatically open URLs from message body in a web browser, for all incoming mails, such as it in in plain text mail.
Where the link is hidden, you could select the text, take it to Word where there is the Hyperlink.Follow Method
Edit: Found it simpler not to go to Word.
Public Sub FollowLinkAddress(itm As Outlook.MailItem)
Dim oDoc As Object
Dim h
Set itm = ActiveInspector.CurrentItem
If itm.GetInspector.EditorType = olEditorWord Then
Set oDoc = itm.GetInspector.WordEditor
For Each h In oDoc.Hyperlinks
h.Follow
Next
End If
End Sub
这篇关于VBA脚本自动对电子邮件中的第一个超链接进行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!