如何使用visual studio 2013将outlook中的未读电子邮件标记为已读
您好,我正在开发outlook插件,它将自动提取文件夹中没有附件的未读电子邮件并将附件提取到文件夹。不过,我能够对从电子邮件提取到文件夹的附件进行编码,但我意识到了两个我应该指出的问题。某些电子邮件可能包含多个附件,而某些附件可能具有相同的文件名(提取时需要自动重命名以防止覆盖)。因此,我无法理解如何对其进行编码?此外,我希望为在特定文件夹中检索到的没有附件的电子邮件编写代码。请提供帮助。下面是从电子邮件中提取文件夹中附件的代码。 公开课如何使用visual studio 2013将outlook中的未读电子邮件标记为已读,outlook,vb.net-2010,Outlook,Vb.net 2010,您好,我正在开发outlook插件,它将自动提取文件夹中没有附件的未读电子邮件并将附件提取到文件夹。不过,我能够对从电子邮件提取到文件夹的附件进行编码,但我意识到了两个我应该指出的问题。某些电子邮件可能包含多个附件,而某些附件可能具有相同的文件名(提取时需要自动重命名以防止覆盖)。因此,我无法理解如何对其进行编码?此外,我希望为在特定文件夹中检索到的没有附件的电子邮件编写代码。请提供帮助。下面是从电子邮件中提取文件夹中附件的代码。 公开课 Private Sub ThisAddIn_Startu
Private Sub ThisAddIn_Startup() Handles Me.Startup
Dim inbox As Outlook.MAPIFolder = Me.Application.ActiveExplorer.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim unreadItems As Outlook.Items = inbox.Items.Restrict("[Unread]=true")
Dim inboxItems As Outlook.Items = inbox.Items.Restrict("[Unread]=true")
Dim newEmail As Outlook.MailItem
MsgBox(String.Format("Unread items in Inbox = {0}", unreadItems.Count))
Try
For Each collectionItem As Object In inboxItems
newEmail = TryCast(collectionItem, Outlook.MailItem)
If newEmail IsNot Nothing Then
If newEmail.Attachments.Count > 0 Then
For i As Integer = 1 To newEmail.Attachments.Count
For j As Integer = i + 1 To newEmail.Attachments.Count
' Dim saveAttachment As Outlook.Attachments = newEmail.Attachments(i)
If newEmail.Attachments(i).FileName.Equals(newEmail.Attachments(j).FileName) Then
newEmail.Attachments(j).SaveAsFile("C:\Attachment\Copy\" & (newEmail.Attachments(j).FileName))
Exit For
End If
Next (j)
newEmail.Attachments(i).SaveAsFile("C:\Attachment\" & (newEmail.Attachments(i).FileName))
Next (i)
End If
End If
Next collectionItem
Catch ex As Exception
If Left(ex.Message, 11) = "Cannot Save" Then
MsgBox("Create Folder C:\Attachment")
End If
End Try
End Sub
在使用System.IO.file.Exists的同时,您当然必须使用自己的逻辑来生成唯一的文件名。一个简单的循环并在名称后面附加一个数字就足以解决文件名冲突 但你所说的“我想要在特定文件夹中检索到没有附件的电子邮件的代码”到底是什么意思呢。是否要挂接到特定文件夹的Folder.Items.ItemAdd事件,以检测新电子邮件何时发送或添加到该文件夹?还是要将没有附件的电子邮件移动到特定文件夹