I am able to send E-mail via the Webmail helper. However, I want to send the message with a body which contains HTML table. Can someone clarify if this is possible in Webmatrix webmail helper.
Yes it is possible. Just specify isBodyHtml: true in the Send method:
var customerRequest = "<p>Help!"</p>";
WebMail.Send(to: email,
subject: "Help request from - " + customerName,
body: customerRequest,
isBodyHtml: true
);
See here for more guidance: http://www.asp.net/web-pages/tutorials/email-and-search/11-adding-email-to-your-web-site
Related
I am using Sendgrid API v3 in a node.js and express environment.
I am using email dynamic templates and easily I can send custom text to the email templates.
But I need also to add attachments and I can't find documentation about that. I need to add attachments in 2 different ways:
There are email that need to have always the same attachments and it would be good for the email template to have its own attachments that is send to the customer inbox not matter what is the server data sent to sendgrid.
If a clinet buys an ebook, this file should be sent by the server, together with the rest of {{{data}}} to Sendgrid and this specific file should be delivered to the client as an attachments.
Can anyone say how to add attachments this way?
Thanks
Not sure if you still need it. But you can send emails using Dynamic Template and Attachments. Reference with their API Doc.
Sample code:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const fs = require("fs");
pathToAttachment = `${__dirname}/attachment.pdf`;
attachment = fs.readFileSync(pathToAttachment).toString("base64");
const msg = {
to: 'test#example.com',
from: 'test#example.com',
subject: 'Sending with SendGrid is Fun',
templateId: "d-11111111111111111111111111",
attachments: [
{
content: attachment,
filename: "attachment.pdf",
type: "application/pdf",
disposition: "attachment"
}
]
};
sgMail.send(msg).catch(err => {
console.log(err);
});
For your 2 cases, why not build a function to send emails with parameters of dynamic template ID and attachments?
sendEmail(
templateId: string,
attachments: Attachment
)
Sendgrid attachments are limited to 30mb which might be too small for what you are trying to do. Sendgrid let's you use the digioh api to send files up to 2gb.
https://digioh.com/sendgrid
An alternative solution would be to send a callback url as text in the email that is linked to an endpoint on your express server that let's users download the data. In this case you would need some additional setup to make sure only users who purchased the items can download them.
I have a simple vuetify contact form and I want to send this forms by email.
I have tried to use a method to send the email, but it does not work, because its on client side. So I get CORS issues.
Here's my code:
async send() {
if (this.$refs.form.validate()) {
try {
const sgMail = require("#sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "test#example.com",
from: "me#mydomain.com",
subject: "Sending with SendGrid is Fun",
text: "and easy to do anywhere, even with Node.js",
html: "<strong>and easy to do anywhere, even with Node.js</strong>"
};
sgMail.send(msg);
}
}
}
Is Express (or an other backend) required? Is there a way to make it work using a middleware?
EDIT
Apparently, it's just not possible: https://github.com/sendgrid/sendgrid-nodejs/issues/730
The CORS policy from Sendgrid does not allow you to use their API from the browser (The 'Access-Control-Allow-Origin' header has a value 'https://sendgrid.api-docs.io').
Quoted from https://sendgrid.com/docs/for-developers/sending-email/cors/ :
In SendGrid's case, we do not allow our customers to make a browser-based call to our v3/mail/send endpoint. (...)
You can create a server-based application, which will protect your API keys from being released to the world. Languages like NodeJS, PHP, Ruby, Python, C#, Go, and Java, and others can be implemented to make calls to the API from the security of a locked down server environment.
You have to send the email from a server, which is a good thing since your API Key would be exposed by the browser otherwise.
If you are using Nuxt in SSR mode (with Node running), I guess you could create a "Server Middleware" ( https://nuxtjs.org/api/configuration-servermiddleware ), for example with a path like "/api/mail", that will send the email.
If you are using nuxt-generate to create a static site, you can use a "function as a service", with something like "https://webtask.io/", to create a small node script; that you can trigger by url from your client to send the email.
I'm working with Dynamics CRM 2016, I want to send an Email from crm using an email address that the user insert (the email Id is taken from a field in incident-Entity and not from crm-user) according to examples online the option is to use entityreference from another entity that will hold and get the Email address, is there a way not to use Entityreference but instead get my email address from a simple field on incident form?
You can use e-mail addresses that are not associated with e-mailaddress fields. It just requires a few steps.
In the UI navigate to Settings > System Settings > tab Email > header "Set Email form options".
Make sure setting "Allow messages with unresolved email recipients to be sent" is Yes.
Now you can use literal e-mail addresses like in this example:
var sender = new EntityCollection();
sender.Entities.Add(new Entity("activityparty")
{
["addressused"] = "me#home.test"
});
var recipients = new EntityCollection();
recipients.Entities.Add(new Entity("activityparty")
{
["addressused"] = "info#acme.test"
});
var eMail = new Entity("email")
{
["from"] = sender,
["to"] = recipients,
["subject"] = "Just a test",
["description"] = "Body of your e-mail"
};
organizationService.Create(eMail);
You can do it programmatically! You can send an email to a person who is not a Lead/Contact/Account.. The CRM will send email but it will show un resolved referenced when you open it in CRM
Update:
but instead get my email address from a simple field on incident form?
This is not possible in CRM UI. But possible using the code snippet from the blog link in comment. You have to query the textbox content and put in recipient party address.
(These two lines are for sending email to activity party email Id from associated record non-email field from CRM UI, without any code or customization for this particular scenario)
Unfortunately you cannot achieve it.
Only way is associated record.
I'm using WinRT and I want to send an email with attachment to a specific recipient programatically, that means the user of the app will not write the recipient address.
I found to solutions that dont correspond to my needs.
the first one is to use mailto protocol like this :
var mailto = new Uri("mailto:?to=ratatata#gmail.com&subject=our first subject &body=as you know this is our first mail baby ");
await Windows.System.Launcher.LaunchUriAsync(mailto);
this solution allow me to specify the recipient but the mailto protocol dont support attachement.
the second one is by using Share Content , like this microsoft sample ,
https://code.msdn.microsoft.com/windowsapps/Sharing-Content-Source-App-d9bffd84
this solution allow me to attach any type of files , but the user of the app should write the email address of the recipient.
NB: any other methods using MessageEmail , and system.net.mail dont work !
Any help please !!
I'm sending the email message from ABAP-report of SAP ECC 6.0 EHP5 to Microsoft Exchange via SMTP. The message reaches user's inbox in Outlook 2013, but it arrives as an attachment instead to be in the body of the message. From the code's point of view, I'm sending the plain text, and I'm expecting to get it inside the message. Since I'm using the default ABAP-approach to sending emails, which sends text inside of an email body, I suppose that the root of the problem is in Exchange/Outlook side.
Is there any Exchange/Outlook setting, which explicitly directs to send the message as an attachment or inside of the message body?
In the examples given, the body is always typed HTM. For the mail body I always use type RAW and this works just fine (with Lotus Notes). So maybe you try the following when creating your mail body:
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = im_text
i_length = txt_len
i_subject = im_subject ).
No, Outlook/Exchange doesn't provide anything for that. I suppose the issue comes from the ABAP/SAP software.