Link to home
Start Free TrialLog in
Avatar of flavo
flavoFlag for Australia

asked on

Open text attachment from Groupwise and import it

Having a bit of trouble with this..

What i want to do:

1. Search a Folder in Groupwise and Open all emails with attachment
2. Import it
3. Delete email


Ive searched all of EE and couldn't really find anything, had a look at the documentation on the Novell site and that didnt really help...  Looked at the Object Browser and i got lost...

If i can get to find the emails that are in there, i should be able to get the rest out...

Anyone done this / know where to look???

Dave
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flavo

ASKER

There was a better link for the Novell site in there..  Better than what i could find!
I know it's a hard to do this and regrettably I have no groupwise nor experience with it to help you further, but hope this triggers some new insights !

Success !

Nic;o)
Avatar of flavo

ASKER

Getting there...
Avatar of flavo

ASKER

its working, but it dies all the time (Excel and Access crash..)

Any ideas???

heres the code - just prints it so far....
Sub PrintAttachments()

Dim oApp As Object
Dim oAcct As Object
Dim oFolders As Object
Dim oFolder As Object
Dim Cnt As Integer
Dim oMessages As Object
Dim oMessage As Message
Dim oAttach As Attachment


Set oApp = CreateObject("NovellGroupWareSession")
Set oAcct = oApp.Login("", "")
If oAcct.Remote = True Then
   'Text1.Text = "Remote"
Else
    'Text1.Text = "Connected"
End If


Debug.Print oAcct.RootFolder.Name
Set oFolders = oAcct.AllFolders
Cnt = 0
For Each oFolder In oFolders
    If oFolder.Name = "BLISSPrint" Then
     Debug.Print oFolder.Name
        Set oMessages = oFolder.Messages
        For Each oMessage In oMessages
       
        Debug.Print oMessage.Subject
           For Each oAttach In oMessage.Attachments
              Debug.Print oAttach.FileName
           Next
        Next
   
 
    End If
Next


Set oApp = Nothing
Set oAcct = Nothing
Set oFolders = Nothing
Set oFolder = Nothing
Set oMessages = Nothing
Set oMessage = Nothing
Set oAttach = Nothing


End Sub
Looks OK to me, did you try to reinstall Office and/or apply the ServiceReleases ?

Nic;o)
Avatar of flavo

ASKER

>> reinstall Office and/or apply the ServiceReleases

Good luck getting the IT guys to do that for me..

It works on my PC, not slower ones... Tested on 4 works on 3 sometimes 2.. Id like it to be a little more stable..
Avatar of flavo

ASKER

this is what im playing with now....

Sub PrintAttachments1()

Dim oApp As Object
Dim oAcct As Object
Dim oFolders As Folders
Dim oFolder As Folder
Dim oMessages As Messages
Dim oMessage As Message
Dim oAttach As Attachment
Dim i As Integer

Set oApp = CreateObject("NovellGroupWareSession")
Set oAcct = oApp.Login("", "")

i = 0

Set oFolders = oAcct.Cabinet.AllFolders

'loop over folders until we get the BLISSPrint area
For Each oFolder In oFolders
    If oFolder.Name = "BLISSPrint" Then
        Set oMessages = oFolder.Messages
        'loop over all the msg's in there
        For Each oMessage In oMessages
          'if its got an attachment (from Subject) then we want the file
          If oMessage.Subject = "BLISS ATTACHMENT" Then
             'loop over the attachments to get the ones we want
             For Each oAttach In oMessage.Attachments
              If oAttach.FileName = "bliss.csv" Then
                'save them in a temp area so we can import them to Excel / Access later - delete them
                oAttach.Save "C:\Documents and Settings\" & UserName & "\BLISS" & i & ".txt"
                'open
                Workbooks.OpenText FileName:="C:\Documents and Settings\" & UserName & "\BLISS" & i & ".txt", _
                Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= _
                Array(Array(0, 9), Array(1, 1), Array(18, 1), Array(26, 1), Array(33, 1), Array(40, 1), _
                Array(47, 1), Array(54, 1), Array(61, 1), Array(68, 1), Array(77, 1))
                DoEvents
               
                i = i + 1
             End If
             'oMessage.Delete
             Next
           
          End If
         
        Next
       
     End If
Next

'clean up
Set oApp = Nothing
Set oAcct = Nothing
Set oFolders = Nothing
Set oFolder = Nothing
Set oMessages = Nothing
Set oMessage = Nothing
Set oAttach = Nothing

End Sub

Is this indeed more stable ?
I see you've added the DoEvents and that does indeed sometimes solve some nasty ones !

Nic;o)
Avatar of flavo

ASKER

I was playing around with them, jamming them in, adding pauses, trying anything!!

I cut down on the number of folders to fly through, that maybe helped...

Just tested on the machine i was having probs with yesterday, and it seemed to work, as long as there aren't too many files in there..

Think it may be getting stuck on saving / opening to many things at once...  Opening it in Excel helped some how... So maybe thats what it was???

I ment to take to code home and compile it to an exe in VB 6, hoping it may be more stable then Excel or Access, but forgot :-(..
The pauses between saving/opening might indeed help, perhaps you could add a pause loop based on the file size.

Nic;o)
Avatar of flavo

ASKER

They're always 5k...

Just tested un commenting the oAttach.Delete and it seemed to work for 26 files, just going to test 30+ and see what happens (should only be about 10 anyway..)

Yep!  Worked for 40 files at a time... Ill do a test on the old laptop and see how we go..

Fingers crossed...
Avatar of flavo

ASKER

Works!
What about storing it first in an Access table to speed up the process ?

Nic;o)
Avatar of flavo

ASKER

Its fast, takes about 5secs to do 40 files... Good enough for me :-)

Its going to be used in Excel anyway, no one else can use Access..