Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 670

•  TDictionary Custom Sort  5 800

•  Fast Watermark Sources  5 603

•  3D Designer  8 218

•  Sik Screen Capture  5 913

•  Patch Maker  6 388

•  Айболит (remote control)  6 378

•  ListBox Drag & Drop  5 237

•  Доска для игры Реверси  94 551

•  Графические эффекты  6 570

•  Рисование по маске  5 644

•  Перетаскивание изображений  4 760

•  Canvas Drawing  5 135

•  Рисование Луны  4 863

•  Поворот изображения  4 411

•  Рисование стержней  3 116

•  Paint on Shape  2 360

•  Генератор кроссвордов  3 228

•  Головоломка Paletto  2 551

•  Теорема Монжа об окружностях  3 328

•  Пазл Numbrix  2 200

•  Заборы и коммивояжеры  2 849

•  Игра HIP  1 820

•  Игра Go (Го)  1 740

•  Симулятор лифта  2 072

•  Программа укладки плитки  1 798

•  Генератор лабиринта  2 240

•  Проверка числового ввода  1 925

•  HEX View  2 226

•  Физический маятник  1 911

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Сохранение прикреплений Outlook



Оформил: DeeCo

{ 
  Won’t some backups of your outlook attachments are filtered 
  some incoming log files? Here's the function. 
}

 uses
   ComObj;

 {...}

 function ManageAttachments(SendersName, AttachmentPath: string;
   MailDelete: Boolean): Boolean;
 var
   oApp: Variant;
   oNs: Variant;
   oFolder: Variant;
   oMsg: Variant;
   AtC: Variant;
   AttFilename: Variant;
   FileName: string;
   CheckSender: string;
   Counter: integer;
   MailCounter: integer;
 begin
   try
     oApp := CreateOLEObject('outlook.application');
     try
       oNs         := oApp.GetNamespace('MAPI');
       ofolder     := oNS.GetDefaultFolder(6); // FolderTypeEnum  (olFolderInbox) 
      MailCounter := 1;
       // If there is any email in the Inbox 
      if ofolder.Items.Count > 0 then
       begin
         repeat
           // Get the first Email 
          oMsg := ofolder.Items(MailCounter);
           // Check the name or Email 
          //   Use CheckSender := oMsg.subject to search on Subject; 
          CheckSender := oMsg.sendername;
           if CheckSender = SendersName then
           //  Remove this line to backup all your attachments. 
          begin
             // Check how many attachments 
            atc := oMsg.Attachments.Count;
             if atc > 0 then
             begin
               // Get all the attachments and save them 
              for Counter := 1 to atc do
               begin
                 AttFilename := oMsg.Attachments.item(Counter).FileName;
                 //filename := IncludeTrailingBackslash(AttachmentPath)+AttFilename; {Use this line for D5)} 
                FileName := AttachmentPath + '\' + AttFilename;
                 oMsg.Attachments.Item(Counter).SaveAsFile(FileName);
               end;
             end;
             if MailDelete then
             begin
               oMsg.Delete;
               // There's 1 Email less, so MailCounter - 1 
              Dec(MailCounter);
             end;
           end;
           // Get the next Email 
          Inc(MailCounter);
           // Do until there is no more Email to check 
        until MailCounter > ofolder.Items.Count;
       end;
     finally
       oApp.quit;
     end;
   except
     Result := False;
     Exit;
   end;
   Result := True;
 end;


 procedure TForm1.Button1Click(Sender: TObject);
 begin
   // ManageAttachments(Email or name, Backup directory, MailDelete yes or no) 
  ManageAttachments('info@cleys.com', 'F:\test', False);
 end;


 { 
  Warning! 
  All your selected Email will be deleted if MailDelete = true 

  Achtung! 
  Alle E-Mails werden geloscht, wenn MailDelete = true ist. 
}







Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте