Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / July 2004

Tip: Looking for answers? Try searching our database.

Read Mails from Outlook n store in SQLServer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
diya gp - 21 Jul 2004 12:54 GMT
Well my requirement is that i want to read the mails from

Outlook and store it in the Database and then delete the stored mails.
have writen the code in Vb which i would want to be written in VbScript
later,
Also Want to write the code in VB 6 without using the MAPI controls.
I have the following code,but am getting an error at the following line
error :-
"Active x Component cannot create object"

Set oSession = CreateObject("MAPI.Session")

The whole code is as follows

Dim oSession As object
Dim oFolder As Object
Dim oMessages As Object
Dim oMsg As Object
Dim oAttachments As Object
'//Varible Define To Pass The Paramater in Function
Dim strEmailToAdd As String
Dim strEmailFromAdd As String
Dim strEmailBody As String
Dim strEmailSubject As String
Dim EmailRecivedDate As Date
Dim EmailSendDate As Date

Set oSession = CreateObject("MAPI.Session")

oSession.Logon "developer5", , True, True
       
Set oFolder = oSession.Inbox
Set oMessages = oFolder.Messages
       
Set oMsg = oMessages.GetFirst
Screen.MousePointer = vbHourglass ' the DeliverNow method could take a
while right?
oSession.DeliverNow ' this now gets all mail services sent and
delivered just as the menu option, tools/deliver now/all services does
       '
While Not oMsg Is Nothing ' If the message collection was empty, oMsg
should be equal to the Nothing object, not "Is" operator takes object
inputs
  If oMsg.Unread = False Then
      strEmailToAdd = oMsg.Sender.Address
      strEmailFromAdd = oMsg.Sender.Address
      strEmailBody = Trim(Replace(oMsg.Text, "'", """"))
      strEmailSubject = Trim(Replace(oMsg.Subject, "'", "''"))
      EmailRecivedDate = oMsg.TimeReceived
      EmailSendDate = oMsg.TimeSent
   End If
     Set oMsg = oMessages.GetNext
  Wend
  Screen.MousePointer = vbDefault ' delivery is now complete so let
them know
   'Explicitly release objects.
       oSession.Logoff
       Set oSession = Nothing
   End If

msgbox(strEmailToAdd ,vbInformation)
msgbox(strEmailFromAdd ,vbInformation)
msgbox(strEmailBody ,vbInformation)

Want help/information about how to create a Mapi.session so as to read
the mails from Microsoft Outlook
Sue Mosher [MVP-Outlook] - 21 Jul 2004 13:34 GMT
MAPI.Session refers to CDO 1.21. Do you have a reference to that library in
your VB project?

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Well my requirement is that i want to read the mails from
>
[quoted text clipped - 62 lines]
> Want help/information about how to create a Mapi.session so as to read
> the mails from Microsoft Outlook
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.