save Attachments from outllook application object

save Attachments from outllook application object

Postby Silvio » Tue Jan 26, 2010 8:09 pm

I found a solution test on vb language : this test save the Attachments on a specific folder

--------------------------------------------------------------------------------------------------------------------

Private Sub ThisApplication_NewMail() Handles Me.NewMail
Dim inBox As Outlook.MAPIFolder = Me.ActiveExplorer() _
.Session.GetDefaultFolder(Outlook. _
OlDefaultFolders.olFolderInbox)
Dim inBoxItems As Outlook.Items = inBox.Items
Dim newEmail As Outlook.MailItem
inBoxItems = inBoxItems.Restrict("[Unread] = true")
Try
For Each collectionItem As Object In inBoxItems
newEmail = TryCast(collectionItem, Outlook.MailItem)
If newEmail IsNot Nothing Then
If newEmail.Attachments.Count > 0 Then
For i As Integer = 1 To newEmail.Attachments.Count
Dim saveAttachment As Outlook.Attachment = _
newEmail.Attachments(i)
newEmail.Attachments(i).SaveAsFile _
("C:\TestFileSave\" & (newEmail _
.Attachments(i).FileName))
Next i
End If
End If
Next collectionItem
Catch ex As Exception
If Left(ex.Message, 11) = "Cannot save" Then
MessageBox.Show("Create Folder C:\TestFileSave")
End If
End Try
End Sub

------------------------------------------------------------------------------------------------

Someone can translate it into FWH Please ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: save Attachments from outllook application object

Postby anserkk » Wed Jan 27, 2010 8:36 am

User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: save Attachments from outllook application object

Postby Silvio » Wed Jan 27, 2010 8:42 am

Dear Ans,

I saw this help many day ago,

I use the test of Otto to drag ONE message from Outlook

THE PROBLEM I ASK IS ANOTHER

When I drag this message

I MUST NOT SAVE ALL ATTACKS OF ALL ATTACKS THERE ARE IN OUTLOOK OF ALL MESSAGES

BUT ONLY THE ATTACKS OF THE MESSAGE I DRAG AND INSERT ON FWH APPLICATION
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: save Attachments from outllook application object

Postby Silvio » Wed Jan 27, 2010 9:15 am

I try with :


function dropread()
local oDlg
LOCAL oOutlook := TOleAuto():New( "Outlook.Application" )
local myOlExp := oOutlook:ActiveExplorer
local oMail
local oGet
local cKategorie := space(50)
local cStichwort := space(50)
local oK := .f.
local dDatum := date()
local dNachfassen := date()+14
local cScanner := GetPvProfString( "SCANNER","MODELL","N",".\INI\WINHOTEL.INI" )
local ziel := ""
local oDatei
local I := 0
local cNotiz := "cNotiz"
local oInhalt
local cDatei := ""
Local oAttach := 1
*--------------------------------------------------------------------------

oMail := myOlExp:Selection:Item(1)
oMail:SaveAs ( "c:\temp\" + "testdemo.msg" )
cNotiz := left(ALLTRIM(oMail:body),1000)
cStichwort := oMail:subject + space(50)



* for each oItem In oInbox:Items
for each oAttach In oMail:Attachments
if valtype( oMail:ReceivedTime) == 'D'
MsgInfo( oMail:ReceivedTime)
else
MsgInfo(valtype( oMail:ReceivedTime))
endif

oMail:SaveAsFile('c:\temp\' + oAttach:filename)

next
*next




but it make error !!

Application
===========
Path and name: C:\work\ERRORI\outlook\xTRich.Exe (32 bits)
Size: 1,915,392 bytes
Time from start: 0 hours 0 mins 8 secs
Error occurred at: 01/27/2010, 10:13:20
Error description: Error Outlook.Application:ACTIVEEXPLORER:SELECTION:ITEM/0 S_OK: SAVEAS
Args:
[ 1] = C c:\temp\testdemo.msg

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:SAVEAS(0)
Called from: testdrop.prg => DROPREAD(47)
Called from: testdrop.prg => (b)MAIN(15)
Called from: .\source\classes\WINDOW.PRG => TRICHEDIT:MBUTTONDOWN(1887)
Called from: xTRich.prg => XTRICH:MBUTTONDOWN(89)
Called from: xTRich.prg => XTRICH:HANDLEEVENT(49)
Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
Called from: => DIALOGBOX(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: testdrop.prg => MAIN(17)




Any Help ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests