Beispiel #1
0
    def setUp(self):

        with open('setup.json') as json_file:
            data = json.load(json_file)

        self.storageApiClient = asposestoragecloud.ApiClient.ApiClient(
            apiKey=str(data['app_key']),
            appSid=str(data['app_sid']),
            debug=True,
            apiServer=str(data['product_uri']))
        self.storageApi = StorageApi(self.storageApiClient)

        self.apiClient = asposeemailcloud.ApiClient.ApiClient(
            apiKey=str(data['app_key']),
            appSid=str(data['app_sid']),
            debug=True,
            apiServer=str(data['product_uri']))
        self.emailApi = EmailApi(self.apiClient)

        self.output_path = str(data['output_location'])
Beispiel #2
0
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client);

#set input file name
fileName =  "email_test2";
name =  fileName + ".eml"
format = "msg"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)

    #invoke Aspose.Email Cloud SDK API to convert message to other formats
    response = emailApi.GetDocumentWithFormat(name, format)

    if(response.Status == 'OK'):
        #download converted email message from api response
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX"  #sepcify App Key
appSid = "XXXXX"  #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(
    apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client)

#set input file name
name = "email_test2.eml"

body = EmailDocument.EmailDocument()

emailBody = EmailProperty.EmailProperty()
emailTo = EmailProperty.EmailProperty()
emailFrom = EmailProperty.EmailProperty()

emailBody.Name = "Body"
emailBody.Value = "This is body"

emailTo.Name = "To"
emailTo.Value = "*****@*****.**"
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client);

#set input file name
name =  "email_test.eml"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)

    #invoke Aspose.Email Cloud SDK API to get email document
    response = emailApi.GetDocument(name)

    if(response is not None):
        for emailProperty in response.DocumentProperties.List:
            print "Property Name :: " + emailProperty.Name
            print "Property Value :: " + emailProperty.Value
Beispiel #5
0
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX"  #sepcify App Key
appSid = "XXXXX"  #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(
    apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client)

#set input file name
name = "email_test2.eml"
attachName = "README.TXT"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)

    #invoke Aspose.Email Cloud SDK API to add attachment to a message
    response = emailApi.GetEmailAttachment(name, attachName)

    if (response.Status == 'OK'):
        #download attachment from api response
        outfilename = "c:/temp/" + attachName
Beispiel #6
0
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client);

#set input file name
name =  "email_test.eml";
propertyName = "Subject"

body = EmailProperty.EmailProperty()
body.Name = "Subject"
body.Value = "This is a new subject"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)

    #invoke Aspose.Email Cloud SDK API to update an email property by name
    response = emailApi.PutSetEmailProperty(name, propertyName, body)
Beispiel #7
0
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX"  #sepcify App Key
appSid = "XXXXX"  #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(
    apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client)

#set input file name
name = "email_test.eml"
propertyName = "Body"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)

    #invoke Aspose.Email Cloud SDK API to get an email property by name
    response = emailApi.GetEmailProperty(propertyName, name)

    if (response.Status == 'OK'):
        print "Property Name :: " + response.EmailProperty.Name
        print "Property Value :: " + response.EmailProperty.Value
Beispiel #8
0
class TestAsposeEmailCloud(unittest.TestCase):
    def setUp(self):

        with open('setup.json') as json_file:
            data = json.load(json_file)

        self.storageApiClient = asposestoragecloud.ApiClient.ApiClient(
            apiKey=str(data['app_key']),
            appSid=str(data['app_sid']),
            debug=True,
            apiServer=str(data['product_uri']))
        self.storageApi = StorageApi(self.storageApiClient)

        self.apiClient = asposeemailcloud.ApiClient.ApiClient(
            apiKey=str(data['app_key']),
            appSid=str(data['app_sid']),
            debug=True,
            apiServer=str(data['product_uri']))
        self.emailApi = EmailApi(self.apiClient)

        self.output_path = str(data['output_location'])

    def testGetDocument(self):

        try:
            name = "email_test.eml"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.emailApi.GetDocument(name)

            self.assertIsInstance(response, EmailDocument.EmailDocument)
            #self.assertEqual(response.Status,'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testGetDocumentWithFormat(self):

        try:
            fileName = "email_test"
            name = "email_test.eml"
            format = "msg"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.emailApi.GetDocumentWithFormat(name, format)

            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testGetEmailAttachment(self):

        try:
            name = "email_test2.eml"
            attachName = "README.TXT"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.emailApi.GetEmailAttachment(name, attachName)

            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testGetEmailProperty(self):

        try:
            name = "email_test.eml"
            propertyName = "Body"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.emailApi.GetEmailProperty(propertyName, name)

            self.assertIsInstance(response,
                                  EmailPropertyResponse.EmailPropertyResponse)
            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testPostAddEmailAttachment(self):

        try:
            name = "email_test.eml"
            attachName = "README.TXT"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.storageApi.PutCreate(attachName,
                                                 '../../../Data/' + attachName)

            response = self.emailApi.PostAddEmailAttachment(name, attachName)

            self.assertIsInstance(response,
                                  EmailDocumentResponse.EmailDocumentResponse)
            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testPutCreateNewEmail(self):

        try:
            name = "email_test2.eml"

            body = EmailDocument.EmailDocument()

            emailBody = EmailProperty.EmailProperty()
            emailTo = EmailProperty.EmailProperty()
            emailFrom = EmailProperty.EmailProperty()

            emailBody.Name = "Body"
            emailBody.Value = "This is body"

            emailTo.Name = "To"
            emailTo.Value = "*****@*****.**"

            emailFrom.Name = "From"
            emailFrom.Value = "*****@*****.**"

            emailProps = EmailProperties.EmailProperties()
            emailProps.List = [emailBody, emailTo, emailFrom]

            body.DocumentProperties = emailProps
            body.Format = "eml"

            #response = self.storageApi.PutCreate(name,'../../../Data/' + name)
            response = self.emailApi.PutCreateNewEmail(name, body)

            self.assertIsInstance(response,
                                  EmailDocumentResponse.EmailDocumentResponse)
            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex

    def testPutSetEmailProperty(self):

        try:
            name = "email_test.eml"
            propertyName = "Subject"

            body = EmailProperty.EmailProperty()
            body.Name = "Subject"
            body.Value = "This is a new subject"

            response = self.storageApi.PutCreate(name, '../../../Data/' + name)
            response = self.emailApi.PutSetEmailProperty(
                name, propertyName, body)

            self.assertIsInstance(response,
                                  EmailPropertyResponse.EmailPropertyResponse)
            self.assertEqual(response.Status, 'OK')

        except ApiException as ex:
            print "Exception"
            print "Code: " + str(ex.code)
            print "Mesage: " + ex.message
            raise ex
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage

apiKey = "XXXXX"  #sepcify App Key
appSid = "XXXXX"  #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"

#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(
    apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Email API SDK
api_client = asposeemailcloud.ApiClient.ApiClient(apiKey, appSid, True)
emailApi = EmailApi(api_client)

#set input file name
name = "email_test.eml"
attachName = "README.TXT"

try:
    #upload file to aspose cloud storage
    response = storageApi.PutCreate(name, data_folder + name)
    response = storageApi.PutCreate(attachName, data_folder + attachName)

    #invoke Aspose.Email Cloud SDK API to add attachment to a message
    response = emailApi.PostAddEmailAttachment(name, attachName)

    if (response.Status == 'OK'):
        #download email from cloud storage