I have been attempting to code a button into my adobe PDF form using an article from quora. The goal is to click a button and it opens an email box with the "to", "subject line", "body" and the "PDF" attaching to the email without having to save the pdf somewhere locally on the clients computer.
These are the three different codes I have found and attempted to use. No matter what I do, I end up getting an "Unterminated String Literal" on line 3 where the body field starts. I have tried adding/removing everything I can think of. ;"'{{:.
Please help if you can! See code below.
var customSubject = this.getField("MyTextField").value;
var mailtoUrl = "mailto:email#email.com?subject=" + Information Form;
this.submitForm({Thank you for your considerate attention to the attached pdf. Let me know if you need anything.; further.
cURL: mailtoUrl, cSubmitAs: "PDF" });
var customSubject = this.getField("MyTextField").value;
var mailtoUrl = "mailto:email#email.com=" + Information Form;
this.submitForm({Thank you for your considerate attention to the attached pdf. Let me know if you need anything.
cURL: mailtoUrl, bPDF:true});
var cToAddr = "email#email.comm"
var cSubLine = "Information Form - " + this.getField(No1LastName) + ", " + this.getField(No2LastName) + "
var cBody = "Please find the attached Information Form. Thank you for your considerate attention to the attached."
this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});
I found that declaring a variable for the email portion worked. I was able to include custom to, cc, subject, and body, as well as attaching the PDF.
var customREmail = this.getField("ReqEmail").value;
var customAEmail = this.getField("AgyEmail").value;
var customAgency = this.getField("Agency").value;
var customLName = this.getField("Lease").value;
var customBAddr = this.getField("BldgAddr").value;
var customBCity = this.getField("BldgCity").value;
var mailtoUrl =
"mailto:XXX#XXX.XXX?cc=" +
customREmail +
"; " +
customAEmail +
"&subject=Compliance%20Request: " +
customAgency +
", " +
customLName +
" - " +
customBAddr +
", " +
customBCity +
"&body=Please review the attached request.%0A%0AThank you,%0A%0A";
this.submitForm({
cURL:mailtoUrl, cSubmitAs:"PDF", bPDF:true
});
Related
I'm trying to read an element from a dynamic website, but am facing a weird (at least to my poor understanding) issue.
Below is a snapshot from the Developer Tool from Chrome
I'm trying to read the innertText of the highlighted line (please note this is a dynamic website, so the "li id's"change).
When I'm firing document.querySelector("#\\31 60698c8-9d6c-492b-acf8-13b82467f873 > div > span.room-display-message-message") in the DevTools Console while highlighting the line as in the above snapshot the innerText is returned, but when I'm moving my selection higher up in the tree, e.g. to "iframe class = "trollbox-iframe" and then running the same script it returns "null".
This behavior also pops up when making the script more random like document.querySelector("* > div > span.room-display-message-message")
Am I getting crazy or is this normal and should I take another approach?
I'm asking this because I'm developing a tool in C# using a CEFSharp Chromium webbrowser to read contents of this website, but that's not relevant at the nmoment
OK, itr took me a few days, but I finally got what I wanted. For those interested here's my solution:
First thing is to add a CefSharp.WinForms.CefSettings to your browser element, being "--disable-web-security"
For calling this trollbox iframe I'm using below Javascript (I know it can be simplified, but hey...it works
var script2 = "function foo(){" +
"var re = /[^-a - zA - Z!, '?\s]/g;" +
"var messages = [];" +
"doc = document.getElementsByClassName('trollbox-container open')[0];" +
"ifrm = doc.getElementsByTagName('iframe')[0];" +
"docInside = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;" +
"docTag = docInside.getElementsByClassName('content small')[0];" +
"msgList = docTag.getElementsByClassName('message-list')[0];" +
"msgList_sender = msgList.getElementsByClassName('room-display-message-sender');" +
"msgList_message = msgList.getElementsByClassName('room-display-message-message');" +
"for (var i = 0; i < msgList_sender.length; i++)" +
" {" +
" var sender = msgList_sender[i].innerText;" +
" var message = msgList_message[i].innerText;" +
" messages.push(sender + ': ' + message);" +
" }" +
"return messages;" +
"}" +
"foo();";
Finally running this code
JavascriptResponse response = await browser1.EvaluateScriptAsync(script2);
returns me the information from the trollbox I wanted
This is the code i have so far.
At the end of the email, I would like to provide social icons like these ones that i found free online. And to lead them to corresponding links i have. Minus the skype.
https://codepen.io/anon/pen/QgjeXw
function sendEmails() {
var allData,counter,emailAddress,fourRowsOfData,i,lastRow,
message,messageStart,messageEnd,numRows,
row,sheet,startRow,studentName,subject;
//USER INPUT
startRow = 2; // First row of data to process
numRows = 4; // Number of rows to process
subject = "Camp Pursuit: Report Card ";
messageStart = "Dear Parents,"+'\n' +'\n' +
"Every week at Camp Pursuit, we ask the teachers to make observations about how the kiddos did." +'\n' +
"We know that one week isn't enough to truly know a child, so we call this our " +"Glows, Grows, & Apropos." +'\n' +
"Meaning..." + '\n' +'\n' +
"Glows: Positive things the teacher noticed" +'\n' +
"Grows: Areas for continued growth" +'\n' +
"Apropos: Ways to continue your son/daughter's enrichment" +'\n' +
"We hope you appreciate seeing what the teachers saw last week, and perhaps you can use some of"+'\n' +
"the recommendations for further enrichment this summer. Feel free to let us know your thoughts on the camp through our anonymous online survey."+'\n' +
"Your feedback helps us improve the experience for all kiddos! "+'\n' +
"Survey Link: https://docs.google.com/forms/d/1g4LvA9a8sdKECr1yvp5uOoPnvKACFm3HvbTBfvQGRyo/viewform?usp=send_form" +'\n' +
"We look forward to seeing your child at our programs throughout the year!" +'\n' +
"Sincerely, "+'\n' +
"The Camp Pursuit Team"
+'\n';
//END USER INPUT
sheet = SpreadsheetApp.getActiveSheet();
lastRow = sheet.getLastRow();
allData = sheet.getRange(startRow, 1, lastRow-startRow, 10);// Get All data first
counter = 0;
while (counter < lastRow-startRow) {
Logger.log('counter: ' + counter)
fourRowsOfData = sheet.getRange(startRow + counter, 1, numRows, 6).getValues();
emailAddress = fourRowsOfData[0][0]; // First column of first row
Logger.log('emailAddress: ' + emailAddress)
studentName = fourRowsOfData[0][1];
messageEnd = "";//Reset on every outer loop
for (i = 0; i < numRows; i++) {//loop numRows times - once for each row
row = fourRowsOfData[i];
messageEnd = messageEnd + '\n' +
"Class: " + row[2] + '\n' +'\n' +
"Glows: " + row[3]+ '\n' +
"Grows: " + row[4] +'\n' +
"Apropos: " + row[5] +'\n';
}
message = messageStart + "\n" + studentName + "\n" + messageEnd;
MailApp.sendEmail(emailAddress, subject, message);//Send the email outside of inner loop
counter+=numRows;//Increment counter by number of rows to process
}
}
I don't think you will be able to use examples from codepen as they involve lots of code (e.g. for displaying hover states, etc). However, you could save the buttons as images and store them in your Drive or elsewhere.
The next step is to get the blob for your image from external URL
var imageBlob = UrlFetchApp.fetch(yourImageUrl).getBlob();
or from Drive
var imageBlob = DriveApp.getFileById(yourFileId).getBlob();
Build the string for the html body of your email. Use 'br' tags for line breaks. Wrap your images in 'a' tags to get them to link to external websites. In 'src' attribute of the 'img' tag, create a unique id for your image blob and put it after 'cid'.
var body = "<h1> Header </h1> <br />" +
"<a href='www.example.com'><img src='cid:uid' /></a> Image <br />" +
"Content";
Instead of string parameters, pass the following object to MailApp.sendEmail() method. At runtime, the script will parse the string stored in 'body' variable and create html output, using cid identifiers to retrieve images from inlineImages object. The property names of 'inlineImages' object must match the ids you put created for your images in 'body'
MailApp.sendEmail({
to: "recipient#example.com",
subject: "subject",
htmlBody: body,
inlineImages: {
uid: imageBlob
}
});
Concatenating the string to produce html body is not the best solution though. Consider creating a reusable html template using HtmlService https://developers.google.com/apps-script/guides/html/
DISCLAIMER: I'm new to Stack Overflow and I'm not a developer.
I work in IT and we are currently trying to take all of our paper/electronic forms and turn them into Google Forms. I am currently trying to write a script (see below) that will send an email to a specific person based on one of the answers. The good news is that the script works (woot!).
The problem that I'm having is that I get 2 - 3 of the exact email when I test it. It's especially bad in with my gmail account.
If the below code looks atrocious, I'm open to suggestions! Thanks in advance for the help!!
function myFunction() {
var form = FormApp.getActiveForm()
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var itemResponses = formResponse.getItemResponses();
var work = itemResponses[3];
var problem = itemResponses[2].getResponse();
var location = itemResponses[4].getResponse();
var name = itemResponses[0].getResponse()
var sheetsLink = docs.google.com/sheetid
}
if (work.getResponse() === "Food Services") {
MailApp.sendEmail('mymail#gmail.com', 'Kitchen Maintenance', name + ' has a problem with ' + problem + ' in the kitchen at ' + location + '. More information for this request can be found at: ' + sheetsLink + '.');
} else {
MailApp.sendEmail('mymail#schoolacct', 'Maintenance', name + ' has a problem with ' + problem + ' at ' + location + '. More information for this request can be found at: ' + sheetsLink + '.');
}
}
It might be easier for you to get the form responses saved in a spreadsheet then tie the apps script to the spreadsheet with an on form submit trigger. This will allow you to have a record of all form responses in the spreadsheet and if anything goes wrong, you can always recheck. On the multiple emails sent, the multiple editors is the thing to check.
I am new to JQuery.
Trying to create a blog page. When user enters name, country and comment, i want to print it out underneath the HTML form.
The script i'm using is as follows:
<script>
$(document).ready(function() {
$(".addButton").click(function() {
var name = $("input[name=name]").val();
var country = $("select[name=countries]").val();
var comment = $("textarea[name=comment]").val();
$(".comments").append("<div class='new-comment'>" + name + " (" + country + "):</br>" + comment + "</div>");
});
});
This prints out my variables but only for a fracture of a second and they disappear. Any explanation would be highly appreciated.
Thank you.
<button> tags will submit the form, causing the page to reload. Use Event.preventDefault() to stop the form submission.
$(document).ready(function() {
$(".addButton").click(function(e) {
e.preventDefault();
var name = $("input[name=name]").val();
var country = $("select[name=countries]").val();
var comment = $("textarea[name=comment]").val();
$(".comments").append("<div class='new-comment'>" + name + " (" + country + "):</br>" + comment + "</div>");
});
});
I've been asked to make unofficial online streaming android application for a certain radio station.
I've experience with streaming in android for certain mp3 or whatever stream.
But I don't know the stream url to provide in mediaPlayer.setDataSource(url).
Is there any way to get the stream url from the ofiicial streaming page for ex. this radio stream?
not that hard,
if you take a look at the page source, you'll see that it uses to stream the audio via shoutcast.
this is the stream url
"StreamUrl": "http://stream.radiotime.com/listen.stream?streamIds=3244651&rti=c051HQVbfRc4FEMbKg5RRVMzRU9KUBw%2fVBZHS0dPF1VIExNzJz0CGQtRcX8OS0o0CUkYRFJDDW8LEVRxGAEOEAcQXko%2bGgwSBBZrV1pQZgQZZxkWCA4L%7e%7e%7e",
which returns a JSON like that:
{
"Streams": [
{
"StreamId": 3244651,
"Reliability": 92,
"Bandwidth": 64,
"HasPlaylist": false,
"MediaType": "MP3",
"Url": "http://mp3hdfm32.hala.jo:8132",
"Type": "Live"
}
]
}
i believe that's the url you need:
http://mp3hdfm32.hala.jo:8132
this is the station WebSite
Edited ZygD's answer for python 3.x.:
import re
import urllib.request
import string
url1 = input("Please enter a URL from Tunein Radio: ");
request = urllib.request.Request(url1);
response = urllib.request.urlopen(request);
raw_file = response.read().decode('utf-8');
API_key = re.findall(r"StreamUrl\":\"(.*?),\"",raw_file);
#print API_key;
#print "The API key is: " + API_key[0];
request2 = urllib.request.Request(str(API_key[0]));
response2 = urllib.request.urlopen(request2);
key_content = response2.read().decode('utf-8');
raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content);
bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content);
reliability = re.findall(r"lity\":(.*?),", key_content);
isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content);
codec = re.findall(r"MediaType\": \"(.*?)\",", key_content);
tipe = re.findall(r"Type\": \"(.*?)\"", key_content);
total = 0
for element in raw_stream_url:
total = total + 1
i = 0
print ("I found " + str(total) + " streams.");
for element in raw_stream_url:
print ("Stream #" + str(i + 1));
print ("Stream stats:");
print ("Bandwidth: " + str(bandwidth[i]) + " kilobytes per second.");
print ("Reliability: " + str(reliability[i]) + "%");
print ("HasPlaylist: " + str(isPlaylist[i]));
print ("Stream codec: " + str(codec[i]));
print ("This audio stream is " + tipe[i].lower());
print ("Pure streaming URL: " + str(raw_stream_url[i]));
i = i + 1
input("Press enter to close")
The provided answers didn't work for me. I'm adding another answer because this is where I ended up when searching for radio stream urls.
Radio Browser is a searchable site with streaming urls for radio stations around the world:
http://www.radio-browser.info/
Search for a station like FIP, Pinguin Radio or Radio Paradise, then click the save button, which downloads a PLS file that you can open in your radioplayer (Rhythmbox), or you open the file in a text editor and copy the URL to add in Goodvibes.
Shahar's answer was really helpful, but I found it quite tedious to do this all myself, so I made a nifty little Python program:
import re
import urllib2
import string
url1 = raw_input("Please enter a URL from Tunein Radio: ");
open_file = urllib2.urlopen(url1);
raw_file = open_file.read();
API_key = re.findall(r"StreamUrl\":\"(.*?),",raw_file);
#print API_key;
#print "The API key is: " + API_key[0];
use_key = urllib2.urlopen(str(API_key[0]));
key_content = use_key.read();
raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content);
bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content);
reliability = re.findall(r"lity\":(.*?),", key_content);
isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content);
codec = re.findall(r"MediaType\": \"(.*?)\",", key_content);
tipe = re.findall(r"Type\": \"(.*?)\"", key_content);
total = 0
for element in raw_stream_url:
total = total + 1
i = 0
print "I found " + str(total) + " streams.";
for element in raw_stream_url:
print "Stream #" + str(i + 1);
print "Stream stats:";
print "Bandwidth: " + str(bandwidth[i]) + " kilobytes per second."
print "Reliability: " + str(reliability[i]) + "%"
print "HasPlaylist: " + str(isPlaylist[i]) + "."
print "Stream codec: " + str(codec[i]) + "."
print "This audio stream is " + tipe[i].lower() + "."
print "Pure streaming URL: " + str(raw_stream_url[i]) + ".";
i = i + 1
raw_input("Press enter to close TMUS.")
It's basically Shahar's solution automated.
When you go to a stream url, you get offered a file. feed this file to a parser to extract the contents out of it. the file is (usually) plain text and contains the url to play.