how to create a zendesk ticket with inline image - zendesk

I would like to create a ticket with inline image but cannot get through it. I am using a rich text having a pasted screen capture image, the content is like
"<img ..."
By using ZendeskApi_V2, I set the Ticket's Comment HtmlBody with the content mentioned but did not work, neither of PlainBody or Body.
Anyone can help, please.
For instance:
In my application, an image is inserted into a RadEditor
By setting the Ticket.Comment as
var ticket = new Ticket {
Comment = new Comment {
HtmlBody = HttpUtility.HtmlDecode(RadEditor.Content)
}
}
After sending the Create Ticket request, I cannot see the inline image in the Zendesk dashboard.
So, did I do it in a right way? How should an embedded or inline image be sent through Zendesk API?

You may need to upload the attachment file first, then you can set the attachment's token in the comment. See here - https://developer.zendesk.com/rest_api/docs/support/tickets#attaching-files

Related

Docusign API and printing documents

I am able to create an e-signature with a pdf on the docusign api that I have setup within the Docusign sandbox. However, one of the requirements for my project is to pre-populate the pdf on docusign and then render it into a browser for printing.
Whenever I create the document within the envelope for e-signature, all of the passed-in fields are in the document. However, if I only create the document, then try to view it, all of the fields I am passing in are blank.
How can I have these passed in fields to stay persistent within the envelope document and then show that document within a browser?
Without seeing your code it's hard to say what you're doing wrong.
I can tell you how it should be done. Not sure what lang you're using. in C# you can do this:
// Add the tabs model (including the SignHere tab) to the signer.
// The Tabs object wants arrays of the different field/tab types
// Tabs are set per recipient/signer
Tabs signer1Tabs = new Tabs
{
SignHereTabs = new List<SignHere> { signHere },
TextTabs = new List<Text> { textLegal, textFamiliar, textSalary }
};
signer1.Tabs = signer1Tabs;
Recipients recipients = new Recipients
{
Signers = new List<Signer> { signer1 }
};
(you can find the full code example and all the other languages in our code example on the Developer Center)

Create inline image that displays properly in iOS mail app

So I have tried 2 different approaches to creating an inline image using c#:
Using an AlternateView
Using an inline Attachement
Option 2 is worse in that it does not appear inline on any of my test clients (outlook 2010/2013, Samsung android email client, ios 10 email client).
Option 1 is almost perfect, all clients display the inline image correctly as long as there are no other attachments. However, if you add a file attachment to the email, only on the iOS email app you get a strange side effect. On iOS, the client displays both the inline image and the attachment as attachments (the inline image is shown as an icon).
I have tried to figure this out by composing an email in Outlook with an embedded image and an attachment. Outlook generates what looks to be two regular attachments (looking at the raw message data from both Outlook and dotNet generated emails), with the image being marked as content-disposition inline. And this works on all my test clients. Except when using the .Net Mail message api to replicate this (option 2), it doesn't work. I am at a loss to understand what is going on here.
Edit 1
What's interesting is that when using Option 2, the email body is delivered encoded as base64. This is different than how the Outlook client manages to do it. There the body is in plain text and the inline attachment image is the only thing encoded in bas64.
Edit 2
Setting the following properties when using Option 2 returns the body to being plain text again:
mail.BodyEncoding = Encoding.UTF8;
mail.BodyTransferEncoding = TransferEncoding.QuotedPrintable;
So to get this to work I had to combine both approaches. Below is what worked for me, it displays the signature image as intended (inline/embedded) image and the attachment as an icon (in iOS anyway). This also displayed correctly on a Samsung Android phone and in outlook 2010/2013. For the sake of simplicity, I will only include the embedded image in the mail body as an example:
var smtpMail = new SmtpClient
using (var mail = new MailMessage())
{
mail.From = new MailAddress(Settings.Default.FromAddress, Settings.Default.FromDisplayName);
mail.To.Add(toAddress);
mail.Subject = subjectText;
mail.IsBodyHtml = true;
mail.BodyEncoding = Encoding.UTF8;
mail.BodyTransferEncoding = TransferEncoding.QuotedPrintable;
mail.Attachments.Add(new Attachment(nonInlinefilePath));
var imgCid = "img001.jpg"
var bodyText = $"<html><body><img src=\"cid:{imgCid}\" alt=\"Sample Image\" /></body></html>";
var altView = AlternateView.CreateAlternateViewFromString(bodyText, Encoding.UTF8, MediaTypeNames.Text.Html);
var inlineFileResource = new LinkedResource(imagePath, MediaTypeNames.Image.Jpeg)
{
TransferEncoding = TransferEncoding.Base64,
ContentId = imgCid,
ContentType =
{
Name = imgCid
},
};
var inlineFileAttachment = new Attachment(imagePath, MediaTypeNames.Image.Jpeg)
{
ContentId = imgCid
};
inlineFileAttachment.ContentDisposition.Inline = true;
inlineFileAttachment.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
altView.LinkedResources.Add(inlineFileResource);
mail.AlternateViews.Add(altView);
mail.Attachments.Add(inlineFileAttachment);
smtpMail.Send(mail);
}
I don't know enough about either email protocols or the iOS email app to know why this is necessary, but after many, many, many different attempts to get iOS mail app to display this properly, this combo was the only one that worked.
I had a similar issue with a work project. Images embedded in the message body using System.Net.Mail LinkedResource, would appear fine in most email clients, but not with iOS emails after a version upgrade during version 10.
The images would have zero bytes and added attachments with zero size. What I did was to fix this was to define the media type, whereas before I didn't.
Before:
LinkedResource logo = new LinkedResource(HttpContext.Current.Server.MapPath("/images/imgname.png"));
After:
LinkedResource(HttpContext.Current.Server.MapPath("/images/imgname.png"), "image/png");
as a possible alternative you could try base64 encoding your image.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADSCAMAAABThmYtAAAAXVB" alt="img" />
I just tested my image in Outlook, outlook for web, and iOS Mail. worked in all for me.
you could use this tool (or any base64 encoder) to generate a base64 image tag
more info here.
another good source of info on this subject

How to fetch mail by id with barbushin imap class

I'm currently working on the imap class by barbushin. It's the only php class over the internet I can find regardless to any encoding issue. Thanks to the coder.
I have a list of messages in a table. Each message sending a message id as GET (say $mid). When a link clicked, the page turned into a view page. It should open that message and display the relevant content right? But it is not. Every message has the same content (the 1st content). The code is designed for gmail but I use it for my client. And it's work.
This is a code:
require_once('../ImapMailbox.php');
define('EMAIL', 'my#domain.com');
define('PASSWORD', '*********');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', EMAIL, PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
$mailId = reset($mailsIds);
$mail = $mailbox->getMail($mailId);
var_dump($mail);
var_dump($mail->getAttachments());
The original is here: https://github.com/barbushin/php-imap
Finally, I found my way home. According to the script there's a line says "mailId". Which is straight forward what is it about.
It was set to the first array by reset(). So the only thing I need to do is extract the message id from it ($mailId is an array of ids). So I simply add an array behind it.
$mailId=$mailsIds[$_GET[uid]];
While $_GET[uid] is a message id sent from a previous page.

Create Snapshot/Thumbnail of a blog entry using mvc

I need to generate a snapshot from multiple links of blogs.
What i have is a list of text like these
"Report: Twitter Will Release Music Discovery App This Month http://on.mash.to/10L1v49 via #mashable"
I want to show the links as snapshot of the blog, followed by its text in my view. Or at least i need to get the picture attached to the blog.
Using facebook debug, http://developers.facebook.com/tools/debug ,i am getting this..
fb:app_id: 122071082108
og:url: http://mashable.com/2013/03/13/twitter-music-app/
og:type: article
og:title: Report: Twitter Will Release Music Discovery App This Month
og:image:
og:description: Twitter is planning to release a standalone music app for iOS called Twitter Music as soon as the end of this month, according to CNET. CNET reports that Twitter Music will help...
og:site_name: Mashable
og:updated_time: 1363267654
I tried the same link from my c# code, accessed the link with parameter 'q' as my desired link. I got the same html as reply but i am unable to find the image associated as it is coming differently for different links.
Can anyone suggest a better method to do this in mvc?
My code in controller to access facebook debug :
var client = new RestClient
{
BaseUrl = "http://developers.facebook.com/tools/debug/og/object"
};
var request = new RestRequest
{
DateFormat = DataFormat.Xml.ToString(),
Resource = "Add",
Method = Method.GET
};
request.AddParameter("q", "http://on.mash.to/10L1v49");
IRestResponse response = client.Execute(request);
var content = response.Content; // raw content as string
What i understand from your question is, you need something like the preview of a link what we get on pasting some link on facebook share area.
Facebook debug method returns an html page which has the image of your blog entry from the link given.
Use HtmlAgilityPack to parse your html returned from facebook debug
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(content);
HtmlNode root = doc.DocumentNode;
var imageurl = doc.DocumentNode.SelectNodes("//img/#src").LastOrDefault();
string imagesrc = imageurl.OuterHtml.ToString();
int start = imagesrc.IndexOf("url=");
int to = imagesrc.IndexOf("\"", start + "url=".Length);
string s = imagesrc.Substring(
start + "url=".Length,
to - start - "url=".Length);
string a = Uri.UnescapeDataString(s);
and..there you have your image of the blog entry. Same function can be modified to retireve the title, description and the updated time of the blog entry.

Embed Documents using LinkedResources for MailMessage

I'm using the following code to embed images into my MailMessage. What I'm trying to do is embed documents (pdf or docx) into the email.
I've tried hyperlink with a link to href="cdi:myDoc.pdf" but that doesn't work. I've also tried using MailMessage.Attachments.Add() but adds the documents in the attachments section instead of embeding the document in the message.
Anyone how to embed a document in the mailmessage? I know Outlook is able to place the attachments in the body of the message but I can't figure how to do it through mailMessage.
Thanks Susan
Sub MultiPartMime()
Dim mail As New MailMessage()
mail.From = New MailAddress("me#mycompany.com")
mail.To.Add("you#yourcompany.com")
mail.Subject = "This is an email"
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<b>this is bold text, and viewable by <img src=""cdi:companylogo""> those mail clients that support html</b>", Nothing, "text/html")
LinkedResource logo = new LinkedResource( "c:\temp\logo.gif" )
logo.ContentId = "companylogo"
htmlView.LinkedResources.Add(logo)
mail.AlternateViews.Add(htmlView)
'send the message
Dim smtp As New SmtpClient("127.0.0.1") 'specify the mail server address
smtp.Send(mail)
End Sub 'MultiPartMime
Try using cid: instead of cdi:. That is one error that comes to mind.
try to use
href="cid:companylogo
(with "cid" instead of "cdi" Like Jakob Mygind suggested) and set it to the contentId that you specified for the LinkedResource.
Also when setting the path to the file, it is good to use the HostingEnvironment.MapPath() method (which is the same of Url.Content() of web projects. It would go with something something like:
LinkedResource logo = new LinkedResource(HostingEnvironment.MapPath("c:\temp\logo.gif"));
Hope it helps!
;)

Resources