|
-
Oct 31st, 2000, 04:37 PM
#1
Thread Starter
Lively Member
I've been using the outlook object, to fetch mail from my mailserver, and insert it into my SQL server database. I am inserting the 'from' address into the database, but, the outlook object does not support a from field! It gives me the persons name who sent the mail, but not the EMAIL address, which I need!
anybody tried this before?
-
Oct 31st, 2000, 07:10 PM
#2
Addicted Member
We fought this battle last week. We looked at several ideas and concluded (with the help of MSDN stating such) that the SendersName is the only field that you can use and that is only good if the user is within your exchange system. It appears that you can create a reply and then parse it out of the body of the message, but that might not be consistant.
-
Nov 1st, 2000, 02:55 AM
#3
Thread Starter
Lively Member
Outlook
So, basically, using the outlook object, there is no way I can get the Senders Email Addres? I can only get thier name?
-
Nov 1st, 2000, 04:54 AM
#4
Member
You could try the following sample code module:
Option Explicit
Private ol As New Outlook.Application
Private ns As Outlook.NameSpace
Private itms As Outlook.Items
Public Sub main()
Dim reply As Outlook.MailItem
Dim i%, j%
Dim s$
StartOutlook
'Retrieve a collection of mail messages in the inbox.
Set itms = ns.GetDefaultFolder(olFolderInbox).Items
'Display The subject and Return Adress for the first Message
With itms(1)
s = "Subject: " & .Subject & vbCrLf & "From: "
Set reply = .reply
For i = 1 To reply.Recipients.Count
s = s & reply.Recipients.Item(1).Address & vbCrLf
Next i
End With
MsgBox s, vbOKOnly + vbInformation, "OUTLOOK INFO"
CleanUpOutlook
End Sub
Function StartOutlook()
'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")
'Let the user logon to Outlook with the Outlook Profile dialog box, then create a new session.
ns.Logon , , True, True
End Function
Function CleanUpOutlook()
'This logs the current profile off of a session.
ns.Logoff
'Release all memory.
Set ns = Nothing
Set ol = Nothing
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|