Results 1 to 7 of 7

Thread: Suggestion Needed for CDO

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    13

    Suggestion Needed for CDO

    Hi,

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    13
    Oups, I press enter to fast before entering the question!

    Here is the post:

    HI, I use CDO to grab unread email from exchange 2000 server and put it into a listview. All work good. The problems is located in the sender area. I need to retreive the email sender adresse (not the frendly name). when I try to retreive it, I got this warning message:
    A Program is trying to access email adress you have stored in outlook. Do you want to alloew this?
    I have the choise of YES or NO. If I choose no, a got exception fault. If I chose YES the maximum time allowed is 10 minutes.

    Can someone can tell me whats wrong?
    1- Do you think that my connection string to the CDO objet is wrong? This connection is suposed to create a new temporary profile to connecte to the exchange server. After the connection, this profile is killed.
    2- Do you think I grab the email adress with the wrong code?

    Here is the code:

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    13
    oups! enter again!!!!

    Here is the code:

    Declared in the contructor
    Code:
            'Open MAPI
            sProfile = txtServeur.Text & vbLf & txtUsager.Text
            Try
                objCDOSession.Logon(, txtPassword.Text, , , , , sProfile)
            Catch
                MsgBox("Error", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Erreur")
                Exit Sub
            End Try
    In the ReadInbox function
    Code:
            Dim objCDOMessageColl As Object
            Dim objCDOFolder As MAPI.Folder
            Dim objCDOMessageFilter As MAPI.MessageFilter
            Dim objCDOMessage As MAPI.Message
            Dim sAdresse As String
            Dim item As ListViewItem
    
            objCDOFolder = objCDOSession.Inbox
    
            If objCDOFolder Is Nothing Then
                MsgBox("Failed to open Inbox")
                Exit Sub
            End If
            'MsgBox("Inbox folder name = " & objCDOFolder.Name)
    
            objCDOMessageColl = objCDOFolder.Messages
            If objCDOMessageColl Is Nothing Then
                MsgBox("Failed to open folder's Messages collection")
                Exit Sub
            End If
    
            objCDOMessageFilter = objCDOMessageColl.Filter
            ' ( ... then validate the message filter before proceeding ... )
            'objCDOMessageFilter.TimeLast = DateValue("07/21/98")
            objCDOMessageFilter.Unread = True ' filter for unread messages
    
            lvTemp.Items.Clear()
    
            ' Message filter is now specified; ready for display loop
            For Each objCDOMessage In objCDOMessageColl ' performs loop, Sets each objMess
                item = lvTemp.Items.Add("")        'SUB0
                'take sender
                sAdresse = objCDOMessage.Sender.Address
                ' If the e-mail sender is an Exchange user, the e-mail address
                ' will return as an X400 address and not an SMTP address.
                ' If the Address property does not return a fully qualified
                ' address (for example, containing an @), try the &H39FE001F MAPI
                ' IMPORTANT: This property is not documented on MSDN.
                If InStr(sAdresse, "@") = 0 Then
                    On Error Resume Next
                    sAdresse = objCDOMessage.Sender.Fields(g_PR_SMTP_ADDRESS_W).value
                End If
                item.SubItems.Add(sAdresse)     'sub1
                item.SubItems.Add(objCDOMessage.Subject) 'Sub2
                item.SubItems.Add(Format(objCDOMessage.TimeReceived, "Short Date") & " - " & Format(objCDOMessage.TimeReceived, "short time")) 'Sub3
                item.SubItems.Add("NA") 'Sub4
                item.SubItems.Add(objCDOMessage.ID) 'sub5
                If objCDOMessage.Importance = 2 Then
                    item.SubItems.Add("Haute") 'sub6                
                Else
                    item.SubItems.Add("Normale") 'sub6                
                End If
            Next
    Thanks for your help!

  4. #4
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    You did nothing wrong, it's just a new microsoft limit. You probably have outlook XP installed which disallow MAPI from grabbing a mail adress (Because of Viruses using those for spreading all over the internet). But, when using it with exchange, i know you can allow certain programs or activeX... to access it, but i don't remember how. Have a look on microsoft web site, they provide a software to allow your programs on your exchange server : msdn link
    Last edited by matt3011; Jul 10th, 2003 at 04:33 PM.

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    You know you can edit your posts right?

  6. #6
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Yes, sorry for the link, i didn't see what i did

  7. #7
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82
    Here is another link, also at MS : Ms link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width