Depends, if your users are using MS Outlook then it would be pretty simple, just add an reference to the MS Outlook object.
Printable View
Depends, if your users are using MS Outlook then it would be pretty simple, just add an reference to the MS Outlook object.
Hi, believe it or not there is no actual email address which you can reference from the incoming email via Outlook Objects.
I tried for ages to work this out and finally I figured that you have to create a copy of the incoming mail object, reply to it and from there you can get the email to respond to;
If anyone has an easier way to get this information, I'm all ears!!!!Code:
'oMail is the current mail object (Incoming mail object)
Dim objMessage As Outlook.MailItem
Dim objMessageCopy As Outlook.MailItem
Dim sEmail As String
Set objMessage = oMail
Set objMessageCopy = objMessage.Reply
sEmail = objMessageCopy.Recipients(1).AddressEntry.Address
' sEmail now holds the reply to email address
Cheers
MarkusJ
Markus,
Of the following 3 statements, which one would be considered the "oMail" object?
Set colApp = CreateObject("Outlook.Application")
Set colNameSpace = colApp.GetNamespace("MAPI")
Set colFolders = colNameSpace.GetDefaultFolder(olFolderInbox)
Thanks,
Jeff
Markus,
I tried your code and I'm not sure if I got it right. Look at my previous message post. I have also attached a screen print of the program. What is supposed to show up in the "E-mail Messages" window are Recipient Email Addresses. Only 1 shows up the way I want it to.
Any ideas?
Thanks,
Jeff
Yo Markus....any ideas?
Does anybody have any idea???
Hi Jeffo..
The following is a piece of code which goes through all the messages in your inbox, looks for a specific subject and then raises an event and passes the current mailobject to a routine.
If you use this inconjunction with the code I posted earlier you should be ok :)
HTHCode:
' Variables used to create the outlook object
Private myOLApp As New Outlook.Application
Private olNameSpace As Outlook.NameSpace
Private myFolder As Outlook.MAPIFolder
Private olMapi As Object
' Subroutine which is used to go through all the emails in the inbox
Public Sub traverse()
Dim i As Integer
Dim strSubject As String
Dim strSender As String
Dim strBody As String
Dim strOwnerBox As String
' For each email in the inbox
For i = 1 To myFolder.Items.Count
' get the subject
strSubject = myFolder.Items(i).Subject
' If the subject is a reponse from the internet site then
If Trim(strSubject) = "|product-purchase|" Then
' Raise the ResponseMail event which will extract all information from the email
' and store the information into the database
RaiseEvent ResponseMail(myFolder.Items(i).SenderName, myFolder.Items(i).Body, myFolder.Items(i).ReplyRecipientNames)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This is the oMail object here
RaiseEvent LogResponse(myFolder.Items(i))
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
Next
End Sub
Regards
Mark
Mark,
I believe your code will work, but I'm not real sure how to integrate it with the code you gave me before.
JO
Hi Jeffo, attached is a form which allows a user to click on a button. All the emails in the Inbox of outlook are then added to a listbox for you to view. To use it create a new project and add the form in, run the form click on the button and all the emails that are in your Inbox should appear in the listbox.
I just wrote this real quick but it should be enough to get you going :)
Don't forget to add a reference to the Microsoft Outlook object library (Im using Microsoft Outlook 9.0 object library)
Cheers
Mark
Markus,
I really appreciate your help in this matter. I did what you said
and unfortunately, it didn't display the email addresses. I've attached a print screen of what the results are. Maybe there are some settings that need to be changed on my computer or something.
Thanks again!
Jeff
Hi Jeffo, Damn thats weird!!
The code that I wrote works ok under Windows 2000 along-side Microsoft Outlook 2000. Unfortunately thats all I have access to...
Whats specs are you using???
Cheers
Mark
Markus,
I'm developing the specs myself. I am running Windows NT and using MS Outlook 97. That output is really strange. I don't know what else to do. How bout you?
Jeff
Hi Jeff, Sorry mate, that really has me baffled
I only have access to outlook 2000 under windows 2000 proferssional...
I really am out of ideas now :(
Hope you get it going somehow
Cheers
Markus