humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | Changelog

save_attachments

save_attachments($path,$to_folder); - Сохранить файлы-вложения из файла-письма. Файл формата приложения Outlook (.msg)

Функция на вход принимает параметры:

  • $path – Путь к файлу
  • $to_folder – целевая папка для сохранения файлов-вложений

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • true – успешно
  • false – не удалось

    Пример использования
    <?php
    // Scenario: Demonstrates how to save attachments from a message file to a specified folder
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    
    // Connect functional objects if not already connected
    if (!isset($path)){
      $path = "../../../Templates/init.php";
      require($path);
    }
    // info
    echo "\n<span >msgfile->" . basename (__FILE__) . "</span>\n";
    
    // Example 1: Save attachments from a message file to a specified folder
    $filePath = "test/test.msg";
    $attachmentsPath = "test/attachments";
    echo("1. Save attachments from message file to folder: $filePath -> $attachmentsPath\n");
    
    // Save attachments using XHEMsgFile
    $saveResult = SYSTEM::$msgfile->save_attachments($filePath, $attachmentsPath);
    
    // Check if attachments were successfully saved
    if ($saveResult) {
        echo("Successfully saved attachments to folder\n");
    } else {
        echo("Failed to save attachments to folder\n");
    }
    
    // end
    echo("\n");
    
    // Quit the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:3035"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>sound.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1. Cохранить аттачменты : ");
    echo(msgfile.save_attachments("test\\test.msg","test\\attachments"));
    
    # конец
    echo("<hr><br>")
    
    # Quit
    app.quit()
    #region using
    
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
    
    #endregion
    
     class Program:XHEScript
     {
    	  static void Main(string[] args)
    	  {
    			// init XHE
    			server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>sound.beep</font><hr>");
    
    			// 1 
    			echo("1. Прочитать заданный файл как текст : \n\n");
    			echo(wordfile.read("test\\test.docx"));
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:3035";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>sound.beep</font><hr>");
    
    // 1 
    echo("1. Сохраним вложения в заданную папку: ");
    echo(msgfile.save_attachments("test\\test.msg","test\\attachments"));
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    msgfile    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .