Open emailclient from Adobe Air with attachment and htmltext - air

Is there a way to open your e-mailclient from adobe air with mail attachment or else with a prefilled htmltext?
Thanks!

Not sure if you can add an attachment like this.
You can prefill subject, body, cc, etc - e.g.
import flash.net.*;
public function mailto():void{
var htmlstr:String = '<b>test</b>';
var url = "mailto:dinesh#dinesh.co.za?subject=test&body="+htmlstr;
var urlReq = new URLRequest(url);
navigateToURL(urlReq);
}

Related

Extract Text from Multipage Attachment PDF Using Google Apps Script

I have a Gmail attachment PDF with multiple scanned pages. When I use Google Apps Script to save the blob from the attachment to a Drive file, open the PDF manually from Google Drive, then select Open With Google Docs, all of the text from the PDF is displayed as a Google Doc. However, when I save the blob as a Google Doc with OCR, only the text from the image on the first page is saved to a Doc, accessed either manually or by code.
The code to get the blob and process it is:
function getAttachments(desiredLabel, processedLabel, emailQuery){
// Find emails
var threads = GmailApp.search(emailQuery);
if(threads.length > 0){
// Iterate through the emails
for(var i in threads){
var mesgs = threads[i].getMessages();
for(var j in mesgs){
var processingMesg = mesgs[j];
var attachments = processingMesg.getAttachments();
var processedAttachments = 0;
// Iterate through attachments
for(var k in attachments){
var attachment = attachments[k];
var attachmentName = attachment.getName();
var attachmentType = attachment.getContentType();
// Process PDFs
if (attachmentType.includes('pdf')) {
processedAttachments += 1;
var pdfBlob = attachment.copyBlob();
var filename = attachmentName + " " + processedAttachments;
processPDF(pdfBlob, filename);
}
}
}
}
}
}
function processPDF(pdfBlob, filename){
// Saves the blob as a PDF.
// All pages are displayed if I click on it from Google Drive after running this script.
let pdfFile = DriveApp.createFile(pdfBlob);
pdfFile.setName(filename);
// Saves the blob as an OCRed Doc.
let resources = {
title: filename,
mimeType: "application/pdf"
};
let options = {
ocr: true,
ocrLanguage: "en"
};
let file = Drive.Files.insert(resources, pdfBlob, options);
let fileID = file.getId();
// Open the file to get the text.
// Only the text of the image on the first page is available in the Doc.
let doc = DocumentApp.openById(fileID);
let docText = doc.getBody().getText();
}
If I try to use Google Docs to read the PDF without OCR directly, I get Exception: Invalid argument, for example:
DocumentApp.openById(pdfFile.getId());
How do I get the text from all of the pages of the PDF?
DocumentApp.openById is a method that can only be used for Google Docs documents
pdfFile can only be "opened" with the DriveApp - DriveApp.getFileById(pdfFile.getId());
Opening a file with DriveApp allows you to use the following methods on the file
When it comes to OCR conversion, your code works for me correctly to convert all pages of a PDF document to Google Docs, so you error source is likely come from the attachment itself / the way you retrieve the blob
Mind that OCR conversion is not good at preserving formatting, so a two page PDF might be collapsed into a one-page Docs - depneding on the formatting of the PDF

How do you send a pdf file using bot framework on a Skype channel?

I would like to send a pdf file using bot-framework on a Skype channel. Similar to how this is done on a telegram channel. Bot Framework: send pdf file on Telegram. I am really struggling to find useful documentation on using the Skype channel with bot-framework. CardAttachments don't work even though they were coming soon two years ago. Like the Telegram example, I have the pdf as a base64 string. I can't use a link as the pdf is generated from the user's inputs.
This is how I send images. I assume it is something similar.
var cardAttachment = new Attachment()
{
ContentUrl = "https://my.url/file.png",
ContentType = "image/png",
Name = "filename.png",
};
var reply = turnContext.Activity.CreateReply();
reply.Attachments = new List<Attachment>() { cardAttachment };
reply.Text = "Some useful text to go along with the image.";
await turnContext.SendActivityAsync(reply, cancellationToken);
I tried
var values = new Dictionary<string, string>();
...
var content = new FormUrlEncodedContent(values);
var response = await Client.PostAsync(#"https://my.url/report.php", content);
var report = await response.Content.ReadAsByteArrayAsync();
var cardAttachment = new Attachment()
{
ContentUrl = "data:application/pdf;base64," + Convert.ToBase64String(report),
ContentType = "application/pdf",
Name = $"{answers.Name}.pdf",
};
var reply = turnContext.Activity.CreateReply();
reply.Attachments = new List<Attachment>() { cardAttachment };
reply.Text = $"{answers.Name} here is your report.";
await turnContext.SendActivityAsync(reply, cancellationToken);
It seems to be close but quite right.
Update: While Skype blocks you from sending PDFs as attachments in any form (links, local file or Base64Strings) you can send them as links by simply embedding the link in your text. It looks like you can send links and local files to WebChat. Sending Bot Reply message with attachment using Bot Framework has lots of examples of various approaches.
I know as of this time last year, the Skype channel did not support sending PDF attachments to users due to security concerns - you can see more details regarding this problem here. I haven't been able to find any recent documentation contrary to that, nor was I able to send a PDF attachment through my test bot to Skype. I could, hower, send a PDF to the Emulator and WebChat. Unfortunately, I believe sending PDF attachments is still unsupported by the Skype channel.
Here is the sample code I used to send a PDF attachment to the emulator and WebChat:
var reply = turnContext.Activity.CreateReply();
// Create an attachment.
var attachment = new Attachment
{
ContentUrl = "<path_to_file>/<filename>.pdf",
ContentType = "application/pdf",
Name = "<filename>.pdf",
};
// Add the attachment to our reply.
reply.Attachments = new List<Attachment>() { attachment };
// Send the activity to the user.
await turnContext.SendActivityAsync(reply, cancellationToken);
Sorry I could not have been of more help.
While Skype blocks you from sending PDFs as attachments in any form (links, local file or Base64Strings) you can send them as links by simply embedding the link in your text.

How to send saved pdf which exists within a folder using .net mvc 5

I am using Rotativa. MVC to generate a PDF from a view, so I can send an email with the PDF as an attachment. The following code does so:
var p = ControllerContext;
var h = new ViewAsPdf("Index") { FileName = "TestViewAsPdfHm.pdf" };
var hmm = h.BuildPdf(p);
var memStream2 = new SysIO.MemoryStream(hmm);
MailMessage mm = new MailMessage("From#gmail.com", "To#gmail.com");
mm.IsBodyHtml = true;
mm.Attachments.Add(new Attachment(memStream2, "BuildPdfOption.pdf"));
My question is "How do I obtain a PDF file saved i.e. in my MVC application's Content/Pdf folder, from within in c# code, so I can attach it to an email in the same manner?"
I have tried many times with file,stream readers and with HttpContext.Server.MapPath, but without success. Using the MapPath option just had a textual document in the email that I couldn't open.

How can I map a Google form submission to a template and email to specific individuals as a PDF?

I am trying to have users submit information through Google forms and have the information inserted into a Google Doc as a template. The completed document would then be converted to a PDF and emailed out to the individual. The issue that I am having is that nothing seems to be produced upon form submission. Help would be appreciated!
Here is the code that I am using:
//Get template from Google Docs and name it
var docTemplate = "1ebZTRMRJTxEkNQl1Y2XTSCmIMhmThSMk3BDEQrJbOBE";
var docName = "Unit Overview Template";
//When Form Gets Submitted
function onFormSubmit(e){
//Get information from form and set as variables
var email_address = "e.values[5]";
var teacher_name = e.values[2];
var unit_name = e.values[6];
var unit_length = e.values[7];
var unit_start = e.values[3];
var course_period = e.values[4];
//Get document template, copy it as a new temp doc, and save the Doc's id
var copyId = DocsList.getFilebyId(docTemplate)
.makeCopy(docName+' for ' +teacher_name)
.getId();
//Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
//Get the document's body section
var copyBody = copyDoc.getActiveSection();
//Replace place holder keys, in our google doc template
copyBody.replaceText('keyFullName', teacher_name);
copyBody.replaceText('keyUnitName', unit_name);
copyBody.replaceText('keyUnitDays', unit_length);
copyBody.replaceText('keyUnitPeriod', course_period);
copyBody.replaceText('keyUnitStart', unit_start);
//Save and close the temporary document
copyDoc.saveAndClose();
//Convert temporary document to PDF
var pdf = DocsList.getFilebyId(copyID).getAs("application/pdf");
//Attach PDF and send the email
var subject = "Unit Lesson Overview";
var body = "Here is your completed Unit Overview for " + unit_name + "";
MailApp.sendEmail(email_address, subject, body, {htmlBody: body, attachments: pdf});
//Delete temp file
DocsList.getFilebyId(copyId).setTrashed(true);
}
Use DriveApp instead of DocsList as the latter is deprecated. Also make sure you have a trigger setup for onFormSubmit under Resources - current project triggers inside the Script Editor.

how to upload a excel file in google doc

use C#,want to upload excel file on google doc. bellow syntax use to upload a xls file
//use Content-Type: text/csv
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "text/csv");
but it's not working ,after upload file convert to csv .But i don't want this conversion.I just want to upload my excel file in my google doc.Help me to upload excel file with out conversion.Thanks in advanced
string USERNAME = "xxx#gmail.com";
string PASSWORD = "xxxxx";
// Start the service and set credentials
DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1");
service.setUserCredentials(USERNAME, PASSWORD);
Authenticator authenticator = new ClientLoginAuthenticator("TestApi", Google.GData.Client.ServiceNames.Documents, service.Credentials);
DocumentEntry entry = new DocumentEntry();
// Set the document title
entry.Title.Text = "Legal Contract";
entry.IsSpreadsheet = true;
// Set the media source
//entry.MediaSource = new MediaFileSource("E:\\New Microsoft Office Word Document.doc", "application/msword");
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "text/csv");
// Define the resumable upload link
Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri);
link.Rel = ResumableUploader.CreateMediaRelation;
entry.Links.Add(link);
// Set the service to be used to parse the returned entry
entry.Service = service;
// Instantiate the ResumableUploader component.
ResumableUploader uploader = new ResumableUploader();
// Set the handlers for the completion and progress events
uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnDone);
uploader.AsyncOperationProgress += new AsyncOperationProgressEventHandler(OnProgress);
// Start the upload process
uploader.InsertAsync(authenticator, entry, new object());
You are passing an xls (Excel) file as a text/csv. If you want to upload as xls, use
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "text/csv");
If you want to upload as xls, use
entry.MediaSource = new MediaFileSource("E:\\Emailcontent.xls", "application/vnd.ms-excel");
Here is the wikipedia/google search that I used:
http://en.wikipedia.org/wiki/Internet_media_type
To ensure documents aren't converted when you upload them, you should also append ?convert=false to the upload uri.