Reading e-mails in Outlook

Reading e-mails in Outlook

Postby driessen » Fri Dec 12, 2008 9:43 am

Hello,

Can someone provide me with a working FWH-example how to read (unread) e-mails in Outlook with attachments ?

Thanks you very much in advance.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Wed Dec 17, 2008 8:22 am

Please ??????????????
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby StefanHaupt » Wed Dec 17, 2008 8:58 am

Michel,

I found this sample in my archive, maybe it helps

Code: Select all  Expand view  RUN
#define olFolderInbox 6


FUNCTION MAIN()

    LOCAL oOutlook := CREATEOBJECT( "Outlook.Application" )
    LOCAL oNameSpace := oOutlook:GetNameSpace("MAPI")
    LOCAL oInbox := oNameSpace:GetDefaultFolder( olFolderInbox )

    LOCAL i

    FOR i = 1 TO oInbox:Items:Count
        ? oInbox:Items[ i ]:Body
        ?
    NEXT

    oOutlook:Quit()

    RETURN NIL
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby driessen » Thu Dec 18, 2008 9:30 am

Stefan,

Thanks a lot for your reaction.

But my problem is : how can I read the attachments ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby StefanHaupt » Fri Dec 19, 2008 8:46 am

Michel,

I did´t find a sample reading attachments, sorry, maybe Enrico can help.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby Otto » Fri Dec 19, 2008 9:51 am

Michael,

you have to extend the code Stefan posted.

The lines are:
For Each anhang In myItem.Attachments
anhang.SaveAsFile myOrt & mail & "_" & anhang.FileName
'MsgBox (anhang.DisplayName)
Next
My code is VBA.

Please post back it it is working.

Regards,
Otto



Code: Select all  Expand view  RUN
Sub SaveEmail()
Dim myItems, myItem As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection


Dim anhang As Outlook.Attachment


myOrt = "c:\whoLIMP\"
On Error Resume Next
'work on selected items
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
'for all items do...
For Each myItem In myOlSel
myItem.SaveAs myOrt & "xxxx.txt", olTXT

myItem.SaveAs myOrt & myItem.EntryID & ".txt", olTXT
myItem.SaveAs myOrt & myItem.EntryID & ".msg", olMSG


For Each anhang In myItem.Attachments
anhang.SaveAsFile myOrt & mail & "_" & anhang.FileName
'MsgBox (anhang.DisplayName)
Next



'myItem.Delete
Next
'free variables
Set myItems = Nothing
Set myItem = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing
End Sub



User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: driessen and 77 guests