Create msg. format attachment from code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 05:25 AM
Hello,
I would like to create msg. outlook attachment from code and attach it to incident.
Below is code which works on 90 percent.
10 percent
Problem start when I download attachment from incident, it doesnt want to be properly opened.
Could somebody help to solve this ?
And how do I can with below code populate some data in msg body and subject?
Nothing help, I have enough roles in outlook read message and it is not opened, so I wonder why it is not properly opened for me.
thanks for helping me on this
/Petr
var attachment = new Attachment();
var attachmentRec = attachment.write("incident", "ef63ddbe0fe587404f6bbb8ce1050eee", "Petr_Test.msg", "msg","TEST"); // sys id to be changed to sys id of the real incident
var attachRec = new GlideRecord("sys_attachment");
attachRec.addQuery("table_sys_id", "ef63ddbe0fe587404f6bbb8ce1050eee"); // sys id to be changed to sys id of the real incident
attachRec.addQuery("file_name", "Petr_Test.msg");
attachRec.query();
attachRec.next();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 05:29 AM
The permissions issue doesn't seem so much like a ServiceNow issue as something local on the computer.
As a test, take a message OUT of Outlook, upload it as a SN attachment, then download it and test the behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 04:31 AM
Hello Chuck,
This works, if I upload msg from outlook to SN, it then open properly.
To my mind Im creating somehow wrongly this msg via script and I dont know what I do wrong.
Would be great, if someone could provide own code how to create email attachment within email action from received email, maybe I then find a trick
Thank you Chuck
/Petr

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2017 06:26 AM
Hi Petr,
The content of the message is going to be the key. I would open the .msg file on your local computer and find out what the format is. It's likely going to have a header with multiple lines (From:, To:, several lines that tell it the server, and other parameters.)
You will then need to create the attachment in that format with the attachment.write() method. A simple string isn't going to be sufficient in this case.
I don't have an example for you as I've not done this before.