Ejemplo n.º 1
0
        public static void Run()
        {
            // ExStart:1
            EmailApi   emailApi   = new EmailApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName   = "email_test2.eml";
            String attachName = "README.TXT";
            String storage    = "";
            String folder     = "";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Email Cloud SDK API to download attachment from email
                ResponseMessage apiResponse = emailApi.GetEmailAttachment(fileName, attachName, storage, folder);

                if (apiResponse != null)
                {
                    System.IO.File.WriteAllBytes(Common.GetDataDir() + attachName, apiResponse.ResponseStream);
                    Console.WriteLine("Download Attachment from Email, Done!");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
Ejemplo n.º 2
0
        public void TestGetEmailAttachment()
        {
            EmailApi   target     = new EmailApi(APIKEY, APPSID, BASEPATH);
            StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH);

            string name       = "email_test2.eml";
            string attachName = "README.TXT";
            string storage    = null;
            string folder     = null;

            storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\email\\resources\\" + name));

            ResponseMessage actual;

            actual = target.GetEmailAttachment(name, attachName, storage, folder);

            Assert.AreEqual(200, actual.Code);
            Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType());
        }