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_test.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)); storageApi.PutCreate(attachName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + attachName)); // Invoke Aspose.Email Cloud SDK API to add attachment an email attachment EmailDocumentResponse apiResponse = emailApi.PostAddEmailAttachment(fileName, attachName, storage, folder); if (apiResponse != null) { Com.Aspose.Storage.Model.ResponseMessage storageRes = storageApi.GetDownload(fileName, null, null); System.IO.File.WriteAllBytes(Common.GetDataDir() + fileName, storageRes.ResponseStream); Console.WriteLine("Add email attachment, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
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 name = "email_test"; String fileName = name + ".eml"; String storage = ""; String folder = ""; EmailDocument body = new EmailDocument(); EmailProperties emailProperties = new EmailProperties(); System.Collections.Generic.List <Link> links = new System.Collections.Generic.List <Link> { }; System.Collections.Generic.List <EmailProperty> empProps = new System.Collections.Generic.List <EmailProperty> { }; Link link = new Link(); link.Href = "http://api.aspose.com/v1.1/pdf/"; link.Rel = "self"; link.Title = "NewField"; link.Type = "link"; links.Add(link); EmailProperty emailBody = new EmailProperty(); EmailProperty emailTo = new EmailProperty(); EmailProperty emailFrom = new EmailProperty(); emailBody.Name = "Body"; emailBody.Value = "This is the Body"; emailBody.Link = link; empProps.Add(emailBody); emailTo.Name = "To"; emailTo.Value = "*****@*****.**"; emailTo.Link = link; empProps.Add(emailTo); emailFrom.Name = "From"; emailFrom.Value = "*****@*****.**"; emailFrom.Link = link; empProps.Add(emailFrom); emailProperties.List = empProps; emailProperties.Link = link; body.DocumentProperties = emailProperties; body.Links = links; try { // Invoke Aspose.Email Cloud SDK API to add new email EmailDocumentResponse apiResponse = emailApi.PutCreateNewEmail(fileName, storage, folder, body); if (apiResponse != null) { Com.Aspose.Storage.Model.ResponseMessage storageRes = storageApi.GetDownload(fileName, null, null); System.IO.File.WriteAllBytes(Common.GetDataDir() + fileName, storageRes.ResponseStream); Console.WriteLine("Add New Email, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }