|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
从其他大佬那边看到的代码,功能是收到了新邮件之后,将附件保存到制定的目录。
请教各位大佬一个问题,在你的帖子里有行代码,
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
If objItem.Class = 43 Then
这个 class = 43,是代表什么意思?不太理解
完整代码如下:
- <div><div style="color: rgb(68, 68, 68); font-family: Tahoma,"Microsoft Yahei","Simsun"; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; overflow-wrap: break-word; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) </div> </div><div> Dim varEntryIDs
- </div>
- Dim objItem As Object
- Dim imail As Outlook.MailItem
- Dim i As Integer
- varEntryIDs = Split(EntryIDCollection, ",") '//????????ID?? Ψ???
- For i = 0 To UBound(varEntryIDs)
- Set objItem = Application.Session.GetItemFromID(varEntryIDs(i)) '//????ID?? ??????????
-
- If objItem.Class = 43 Then
- Set imail = objItem
- Call NewMailSaveAttachemnets(imail) '//?????????
-
- End If
-
- Next
- '// MsgBox "?????" & UBound(varEntryIDs) & "??? "
- End Sub
复制代码- Sub NewMailSaveAttachemnets(myMail As Outlook.MailItem)
- '// outlook ?????????? ?????????? ?????????λ??
- On Error Resume Next
- Dim mail As Outlook.MailItem
- Dim Fso As Object
-
-
- Dim myOlExp As Outlook.Explorer '//outlook
- Dim myOlSel As Outlook.Selection '//outlook?????????
- Dim MyFileName As String
-
- Set myOlExp = Application.ActiveExplorer '//?????? outlook
- Dim vItem As Outlook.Attachment
- If myMail.Attachments.Count > 0 Then
- For i = 1 To myMail.Attachments.Count
-
- Set vItem = myMail.Attachments(i)
- MyFileName = vItem.Filename
- vItem.SaveAsFile Folder & "" & vItem.Filename '//???渽??·??
- Next i
- End If
- End Sub
复制代码
|
|