Email an attachment

Solved!
newuser
Level 2
Email an attachment

I am looking to send an excel file as an attachment. With the below code though I receive an email the attachment seems to be missing, any help is appreciated, thanks.

 

    s = MessageSender(channel_id='aaa', 
                  type='mail-scenario', 
                  configuration={"sender":"email@abc.com",  
                                 "subject":"An attcahment"})
    mailing_message= 'PFA'
    attachment ={
                  'type': 'xlsx',
                  'params':
                    {'folderId': 'PROJECT_KEY',
                      'attachedItemPath': 'complete_path_of_file'}
                }
    s.send(project_key="PROJECT_KEY",
           recipient="email@abc.com", 
           message=mailing_message,
          attachments=[attachment])

 

0 Kudos
1 Solution
MarcH
Dataiker

Hello,

In your attachment object, you seem to be wanting to send an item from a folder, so you should change the attachment "type" to "FOLDER_ITEM" instead of "xlsx".

Also, you have "PROJECT_KEY" as your "folderId", double check that you are actually putting the folder id in that field rather than the project key.

View solution in original post

3 Replies
MarcH
Dataiker

Hello,

In your attachment object, you seem to be wanting to send an item from a folder, so you should change the attachment "type" to "FOLDER_ITEM" instead of "xlsx".

Also, you have "PROJECT_KEY" as your "folderId", double check that you are actually putting the folder id in that field rather than the project key.

newuser
Level 2
Author

Hi, Thanks for the reply, I changed the attachment type to "FOLDER_ITEM".

What is a "folderId" and where can I find that?

0 Kudos
MarcH
Dataiker

The excel file you want to attach must be in a managed folder in your DSS project. The folder id can be found in the URL when you are viewing the contents of the managed folder. For example, you should see a URL that looks like: ".../projects/[project key]/managedfolder/[folder id]/view/"