2010-04-09 6 views
0

Outlook Express의 전자 메일을 표시 할 때 vb.net을 사용하고 있습니다! 모든 것이 잘 작동하지만 일부 메시지에 첨부 파일이있는 경우 전자 메일에 첨부 파일이 있다는 메시지를 표시 할 수 없습니다!메일 첨부 파일 확인

이 내 코드입니다 :

나는 이메일 첨부 파일이 있다는 메시지를 표시 할 수있는 방법
Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click 
    Dim oItem 
    Dim i As Integer 
    Dim Message As MAPI.Message 
    Dim items As String() = New String(6) {} '  Items are the sender name,subject and date and  read/unread value 
    Dim PrSenderEmail, PrBodyEmail 
    Session = CreateObject("MAPI.Session") ' we use a session object of MAPI Component 
     Session.Logon(ProfileName:=Me.UserId.Text, ProfilePassword:=Me.Password.Text) 
     Session.MAPIOBJECT = Session.MAPIOBJECT ' 
     Folder = CObj(Session.Inbox) ' choose the folder 
     Application = CreateObject("Outlook.Application") 
     Namespace1 = Application.GetNamespace("MAPI") 
     Namespace1.Logon() 
     ' for getting the sender name and avoid security validation of Outlook/Exchange server 2003 
     ' we are using the "Redemption" component 
     sItem = CreateObject("Redemption.SafeMailItem") 
     Cursor.Current = Cursors.WaitCursor ' show we're busy doing the sort 
     ListInbox.BeginUpdate() ' Notify that update begins 
     ListInbox.Items.Clear() 
     i = 0 ' first email message is 0 
     For Each Message In Folder.Messages 
      Try 
       i = i + 1 ' increment to the next email message 
       'get e-mail from the Inbox, can be any other item 
       oItem = Application.Session.GetDefaultFolder(6).Items(i) ' GetDefaultFolder(6) refers to Inbox 
       sItem.Item = oItem 
       'sItem is an object of Redemption COM and is used to get the senders name 
       items(0) = sItem.SenderName() 
      Catch 
       items(0) = "error" 
      End Try 
      Dim objApp As Outlook.Application = New Outlook.Application 
      'Get Mapi NameSpace 
      Dim objNS As Outlook.NameSpace = objApp.GetNamespace("MAPI") 
      Dim oMsg As Outlook.MailItem 
      Dim pp As String 
      Dim b As Integer 
      Dim objAttachment As Outlook.Attachment 
      pp = Message.StoreID 
      items(1) = Message.Subject 
      items(2) = Message.TimeReceived 
      items(4) = Message.Subject 
      items(5) = Message.Size 
      Dim objInbox As Outlook.MAPIFolder = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) 
      Dim objItems As Outlook.Items = objInbox.Items 
      items(5) = Message.Size.ToString/1000 & "kb" 
      If Message.Unread = True Then 
       items(3) = "unread" 
      Else 
       items(3) = "read" 
      End If 
      ListInbox.Items.Add(New ListViewItem(items)) 
     Next 
     ListInbox.EndUpdate() ' Notify that update ends 
     Cursor.Current = Cursors.Default 
    End If 
End Sub 

?

+0

여기에 3 세트의 코드를 붙여 넣은 것처럼 보입니까? – 76mel

답변

1

왜 Message.Attachments.Count를 사용하지 않습니까?

관련 문제