Scan Outlook Inbox and extract text file attachment

rakeshranjanrakeshranjan Member Posts: 18
Hi All

Does anybody helpme out in Scan inbox attached with text file and save it to a diffrent folder or process it directly .



Regards
Rakesh Ranjan

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This is complex to do and I don't think someone will just post this code as an answer to this question.

    What have you tried yourself? Is your solution 95% finished or are you hoping for a free-of-charge solution.

    Personaly I would not interface with outlook but directly with exchange via the NAS.
  • rakeshranjanrakeshranjan Member Posts: 18
    I Have Done some coding on it, it scan and save the attached file to the specific folder , But having problem it not filter the sender and attached file i think it is completed by 80 %.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I see.

    It wil help if you post the code.

    Do you use a dedicated mailbox for this solution? That usually helps so you can just process al emails that enter the inbox.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    This function copies attachments in mails to a given directory:
    fctCopyAttachments(ptxtID : Text[250];ptxtDirectory : Text[250];VAR pintNumberOfMails : Integer)
    //fctCopyAttachments
    
    olMapiFolder := olNameSpace.GetFolderFromID(ptxtID);
    ltxtFindCriteria := '[Subject] = ''All mails containing this text''';
    olItems := olMapiFolder.Items.Restrict(ltxtFindCriteria);
    
    //Save attachments to directory
    i := 1;
    lintEndOfLoop := olItems.Count;
    WHILE i <= lintEndOfLoop DO BEGIN
      olMItem := olItems.Item(i);
    
      olAttachments := olMItem.Attachments;
      IF olAttachments.Count = 1 THEN BEGIN
        olAttachment := olAttachments.Item(1);
        olAttachment.SaveAsFile(ptxtDirectory + '\' + olAttachment.FileName);
      END;
    
      i := i + 1;
    END;
    
    pintNumberOfMails := lintEndOfLoop;
    
    CLEAR(olItems);
    CLEAR(olMItem);
    CLEAR(olAttachments);
    CLEAR(olMapiFolder);
    

    This function moves mails from one Outlook folder to another OL folder:
    fctMove2Folder(ptxtID : Text[250];ptxtID2 : Text[250])
    //fctMove2Folder
    
    olMapiFolder := olNameSpace.GetFolderFromID(ptxtID);
    olMapiFolder2 := olNameSpace.GetFolderFromID(ptxtID2);
    ltxtFindCriteria := '[Subject] = ''All mails containing this text''';
    olItems := olMapiFolder.Items.Restrict(ltxtFindCriteria);
    
    FOR i := 1 TO olItems.Count DO BEGIN
      olMItem := olItems.Item(i);
      olMItem.Move(olMapiFolder2);
      CLEAR(olMItem);
      i := 999999;
    END;
    
    CLEAR(olItems);
    CLEAR(olMItem);
    CLEAR(olMapiFolder);
    CLEAR(olMapiFolder2);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • rakeshranjanrakeshranjan Member Posts: 18
    Thanks a lot , I got what i want... i also thanks a lot to mibuso team, who has developed such a gr8 forum for dynamics user.

    Regards
    Rakesh Ranjan
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    The idea of a forum is to learn from each other, not just consume. I am still curious where your problem was and how your code looks.
Sign In or Register to comment.