Hi,
Printable View
Hi,
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:
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.Quote:
A Program is trying to access email adress you have stored in outlook. Do you want to alloew this?
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:
oups! enter again!!!! :mad:
Here is the code:
Declared in the contructor
In the ReadInbox functionCode:'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
Thanks for your help!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
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
You know you can edit your posts right?
Yes, sorry for the link, i didn't see what i did
Here is another link, also at MS : Ms link