Want my google forms to send an email to the respondent email they entered to specific cell - google-forms

This the code I am using
function sendEmail(e) {
//response
//getRespondentEmail()
var html = HtmlService.createTemplateFromFile("htmlEmail.html")
var htmlText = html.evaluate().getContent();
var emailTo= e.response.getRespondentEmail();
var subject = "Thanks for participation";
var textBody = "This email requires HTML support. Please make sure you open with a client that supports it."
var options = { htmlBody : htmlText };
var ss = SpreadsheetApp.openById("B!");
if (emailTo!== undefined){
GmailApp.sendEmail(emailTo, subject, textBody, options)
}
}
However, the problem with this code that it relies on google getting the email (through a mandatory cell)
What I want is to make it optional for the particpant to enter their email or not in a specific cell.
Then I want the code to read that email in the specified cell and send an email to it.
Thanks

Related

How to set url or email or special character to cookie in Asp.net core 3.0?

I want to set cookie using asp.net core. i use this code to add cookie
CookieOptions options = new CookieOptions();
options.Expires = DateTime.Now.AddDays(5);
Response.Cookies.Append("email", "hello#gmail.com", options);
But in cookie email is not store as it is . its like hello%gmail.com . I can store the url and email into cookie.
Any help. Thank you
As far as I know, if you store the cookie in the response, it will use url encrypt the cookie by default.
When you checked the client cookie, it will store as below:
This will not affect reading cookie in your asp.net core backend codes.
The source codes will decrypt the cookie value by default to let you see the result.
More details, you could refer to below example:
var re = Request.Cookies["email"];
Result:
I try to read the cookie using Javascript and it seems it not show as it should
If you want to read the cookie from js, you should use decodeURIComponent
method to decode it.
More details, you could refer to below codes:
$(document).ready(function () {
var read_cookies = document.cookie;
var split_read_cookie = read_cookies.split(";");
for (i = 0; i < split_read_cookie.length; i++) {
var value = split_read_cookie[i];
value = value.split("=");
if (value[0] == " email" ) {
alert(value[1]);
alert(decodeURIComponent(value[1]));
}
}
});
Result:

When I create a docusign template with fields, that if I send it to other people using API the fields disappear?

ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
List<string> scopes = new List<string>
{
OAuth.Scope_SIGNATURE,
OAuth.Scope_IMPERSONATION
};
docuSign_JWT testConfig = new docuSign_JWT();
testConfig.ApiClient = new ApiClient(testConfig.Host);
// If this is the first time logging in - Get Consent from the user - this is a onetime step.
Uri oauthURI = testConfig.ApiClient.GetAuthorizationUri(testConfig.IntegratorKey, scopes, RedirectURI, OAuth.CODE, "testState");
Process.Start(oauthURI.ToString());
var privateKeyStream = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(testConfig.PrivateKeyFilename));
OAuth.OAuthToken tokenInfo = testConfig.ApiClient.RequestJWTUserToken(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, privateKeyStream, testConfig.ExpiresInHours);
apiClient = new ApiClient("https://demo.docusign.net/restapi");
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + tokenInfo.access_token);
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.EmailSubject = "Please sign this document";
envelopeDefinition.TemplateId = "***************";
DocuSign.eSign.Model.TemplateRole cc1 = new DocuSign.eSign.Model.TemplateRole();
cc1.Email = "Email1 default template recipient";
cc1.Name = "Name";
cc1.RoleName = "Staff";
DocuSign.eSign.Model.TemplateRole cc2 = new DocuSign.eSign.Model.TemplateRole();
cc2.Email = "Email2 new email ID";
cc2.Name = "Name2";
cc2.RoleName = "Staff";
DocuSign.eSign.Model.TemplateRole cc3 = new DocuSign.eSign.Model.TemplateRole();
cc3.Email = "Email3 new Email ID";
cc3.Name = "Name3";
cc3.RoleName = "Staff";
List<DocuSign.eSign.Model.TemplateRole> templateRoles = new List<DocuSign.eSign.Model.TemplateRole>();
templateRoles.Add(cc1);
templateRoles.Add(cc2);
templateRoles.Add(cc3);
envelopeDefinition.TemplateRoles = templateRoles;
envelopeDefinition.Status = "sent";
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(ConfigurationManager.AppSettings["accountID"], envelopeDefinition);
Above is my code to send docuSign template document. But only default recipient get document with fields, other recipient get only pdf file without fields.
How to send template document with fields to all recipient.
below is template fields img
Thank you
enter image description here
It looks like all three of your recipients have the same RoleName, which means there's going to be an issue mapping each recipient to their role.
Template Role Names should be unique, and their definition in the API call need to match exactly what is present in the template. When setting up roles to be populated by through the API, it's also important to make sure that only the RoleName field is filled out. If a template has a "burned in" name and email address, you won't be able to populate them in your API call.
Can you grab a screenshot of how the recipients are set up on the template in the web console? Like this:

Inline image rendered twice by OSX mail app

My .NET 4.5 web application uses class SmtpClient to create and send e-mail messages to various recipients.
Each e-mail message consists of:
an HTML message body
an embedded inline image (JPeg or PNG or GIF)
an attachment (PDF)
Sample code is below. It works fine, but there is one gripe from OSX users. Apple's standard mail app renders the image twice; once inlined in the message body, and again following the message body, next to the preview of the PDF attachment.
I tinkered with the following properties; none of which would help.
SmtpClient's DeliveryFormat
MailMessage's IsBodyHtml and BodyTransferEncoding
Attachment's MimeType, Inline, DispositionType, ContentId, FileName, Size, CreationDate, ModificationDate
If I compose a similar e-mail message in MS Outlook and send it off to the Apple user, the image is rendered once, inlined in the message body; exactly as I would like it to be. So apparently it is possible.
After reading this, I inspected the raw MIME data, and noticed Outlook uses multipart/related to group together the message body and the images.
My question:
How do I mimic Outlook's behavior with the classes found in System.Net.Mail?
Things I would rather not do:
Employ external images instead of embedded ones (many e-mail clients initially block these to protect recipient's privacy).
Use third party libraries (to avoid legal hassle). The SmtpDirect class I found here seems to solve the problem (though I got a server exception in return), but it is hard for me to accept a complete rewrite of MS's SmtpClient implementation is necessary for such a subtle change.
Send the e-mail message to a pickup folder, manipulate the resulting .eml file, push the file to our Exchange server.
Minimal code to reproduce the problem:
using System.IO;
using System.Net.Mail;
using System.Net.Mime;
namespace SendMail
{
class Program
{
const string body = "Body text <img src=\"cid:ampersand.gif\" /> image.";
static Attachment CreateGif()
{
var att = new Attachment(new MemoryStream(Resource1.ampersand), "ampersand.gif")
{
ContentId = "ampersand.gif",
ContentType = new ContentType(MediaTypeNames.Image.Gif)
};
att.ContentDisposition.Inline = true;
return att;
}
static Attachment CreatePdf()
{
var att = new Attachment(new MemoryStream(Resource1.Hello), "Hello.pdf")
{
ContentId = "Hello.pdf",
ContentType = new ContentType(MediaTypeNames.Application.Pdf)
};
att.ContentDisposition.Inline = false;
return att;
}
static MailMessage CreateMessage()
{
var msg = new MailMessage(Resource1.from, Resource1.to, "The subject", body)
{
IsBodyHtml = true
};
msg.Attachments.Add(CreateGif());
msg.Attachments.Add(CreatePdf());
return msg;
}
static void Main(string[] args)
{
new SmtpClient(Resource1.host).Send(CreateMessage());
}
}
}
To actually build and run it, you will need an additional resource file Resource1.resx with the two attachments (ampersand and Hello) and three strings host (the SMTP server), from and to (both of which are e-mail addresses).
(I found this solution myself before I got to posting the question, but decided to publish anyway; it may help out others. I am still open for alternative solutions!)
I managed to get the desired effect by using class AlternateView.
static MailMessage CreateMessage()
{
var client = new SmtpClient(Resource1.host);
var msg = new MailMessage(Resource1.from, Resource1.to, "The subject", "Alternative message body in plain text.");
var view = AlternateView.CreateAlternateViewFromString(body, System.Text.Encoding.UTF8, MediaTypeNames.Text.Html);
var res = new LinkedResource(new MemoryStream(Resource1.ampersand), new ContentType(MediaTypeNames.Image.Gif))
{
ContentId = "ampersand.gif"
};
view.LinkedResources.Add(res);
msg.AlternateViews.Add(view);
msg.Attachments.Add(CreatePdf());
return msg;
}
As a side effect, the message now also contains a plain text version of the body (for paranoid web clients that reject HTML). Though it is a bit of a burden ("Alternative message body in plain text" needs improvement), it does give you more control as to how the message is rendered under different security settings.

Not getting WeChat Follow response

I have a Debugging Official Account with WeChat. I have entered my public URL and Token into the field provided http://admin.wechat.com/debug/sandbox and also attempted debugging the request with http://admin.wechat.com/debug/
My ASP.Net [.Net4.5] Web API application's POST Method looks like the following :
public HttpResponseMessage PostMessage([FromBody]Strikemedia.Api.WeChat.TextMessage value)
{
if (value == null)
{
var richMediaMessage = new RichMediaMessage();
richMediaMessage.touser = value.FromuserName;
//Create Article
var item = new Article()
{
title = "Didn't receive anything back",
description = "Mind entering 'test'",
picurl = "URL",
url = "URL"
};
var articles = new List<Article>();
articles.Add(item);
richMediaMessage.articles = articles;
richMediaMessage.articleCount = articles.Count;
return Request.CreateResponse(HttpStatusCode.OK, richMediaMessage, "application/json");
}
var exploded = value.Content.Split(' ')[0];
var richMedia = new RichMediaMessage();
richMedia.touser = value.FromuserName;
//Create Article
var article = new Article() {
title = response.KeywordDescription,
description = response.Response,
picurl = "URL",
url = "URL"
};
var _articles = new List<Article>();
_articles.Add(article);
richMedia.articles = _articles;
richMedia.articleCount = _articles.Count;
//Return response
var resp = Request.CreateResponse(HttpStatusCode.OK, richMedia, "application/json");
//resp.RequestMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
return resp;
}
It needs to respond with a RichMessageType in JSON format and is received in XML format
Am i missing something or have i overlooked something?
Can you confirm that you have submitted the URL and token into admin.wechat.com and that the URL and token was accepted?
Also note you get XML and you respond with XML no json response.
Have you had a look at: http://youtu.be/kB20Zf51QWU
And then this
http://youtu.be/_2FSzD2B2F0
This is the documentation for the XML can be found when you google "wechat guide to message api"
So if you still not receiving a success message when submitting your app on admin.wechat.com then you can send me your test URL here. To find this URL check your access logs to see exactly what URL wechat is calling. Then post it here. Please note that when you hit the URL as wechat will you should only see the "echostr" printed on the screen (when viewing the source in your browser). No XML no HTML just the echostr.
Also make sure there are no spaces or newlines after or before the "echostr". When you view the source it should only be one line which is the echostr GET param's value.
The XML response only comes in later when you actually start responding to messages from users. For now Wechat is just confirming if your security is setup correctly.
Also note if your server is load balanced you will have to skip the signature validation and build your own validation when a echostr GET parameter gets passed through and only echo the "echostr" param to screen.

Open an email message from Flex with the body of the email message populated

I want to set up an email from Flex so that when I press a button it opens a new message from the default mail program. (In most cases this will be Outlook). I have got something that uses mailTo: and open an new message with the to email address filled in. What I want is to populate the message part of the email. I am not overly concerned with who is in the to: line. I just want the message part populated.
Is this possible in Flex?
Thanks
Here is a sample to populate the email body
var mailMsg:URLRequest = new URLRequest('mailto:' + recipients);
var variables:URLVariables = new URLVariables();
variables.subject = mailSubject;
variables.body = mailBody;
mailMsg.data = variables;
mailMsg.method = URLRequestMethod.GET;
navigateToURL(mailMsg, "_self");

Resources