How to send email in Microsoft Azure using SendGrid [closed] - email

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
In Microsoft Azure website, how can we send email using SendGrid?

You need to get SendGrid UserId & Key from Azure, and then use below code to send email:
public void SendEmail(string emailTo, string emailSubject, string emailBody)
{
try
{
//Create the email object first, then add the properties.
SendGrid myMessage = SendGrid.GetInstance();
myMessage.AddTo(emailTo);
myMessage.From = new MailAddress("abc#xyz.com", "Abc Xyz");
myMessage.Subject = emailSubject;
myMessage.Text = emailBody;
// Create credentials, specifying your user name and password. (Use SendGrid UserId & Password
var credentials = new NetworkCredential("azure_xxxxxxxxxxxxxxx#azure.com", "xxxxxxxxxxxx");
// Create an Web transport for sending email.
var transportWeb = Web.GetInstance(credentials);
//Send the email.
transportWeb.DeliverAsync(myMessage);
}
catch (Exception ex)
{
string msg = ex.Message;
}
}
More more info you can refer following link http://sendgrid.com/docs/Code_Examples/csharp.html

Related

Laravel more time using token [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I would like to know how can I remove token in form POST method because when I need between 10 and 15 min to fill a form and when I send it, I receive a token exception and I lost all my data.
Thank's for help
I wouldn't recommend removing the token. Instead increase the expiry time or after post redirect back with input values.
public function render($request, Exception $e)
{
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->back()->withInput()->with('token', csrf_token());
}
return parent::render($request, $e);
}

ccing using SendGrid Service in Bluemix

Trying to use SendGrid Service in Bluemix coding in Node.js. I use the addCc() method to add an address to cc to. I get no error msg and the mail is delivered to the main address, but nothing gets sent to the cc:ed address. And if I look ath the top of the mail going to the main recipient I can see the cc address there. Does anyone know if there is a bug or limitation in using cc with SendGrid?
Best Regards
W
A common error is to pass an array to the addCc() function when it expects a string. Using v2.0.0 of the 'sendgrid' npm module, the code below will correctly send an email which cc's 'jennifer#electric.co'.
As mentioned in the comment above, verify that you're not hitting issue https://github.com/sendgrid/sendgrid-nodejs/issues/162
// Pre-req: get the SendGrid credentials for username and password
// from VCAP_SERVICES into the 'user' and 'pass' vars
var sendgrid = require('sendgrid')(user, pass);
var email = new sendgrid.Email({
to: 'fargo.north#electric.co',
from: 'bronco.bruce#electric.co',
subject: 'SendGrid Test',
text: 'This is a SendGrid test'
};
// add a cc address as a single string
email.addCc('jennifer#electric.co');
sendgrid.send(email, function(err, json) {
if (err) {
return console.error(err);
}
console.log(json);
}

Google Script email also being sent to account owner?

I have a problem with a Google MCC Script I have. It's set up to run every day in the early hours of the morning, do some processing, and email out a result, using Google Scripts' built in MailApp.sendEmail function.
The problem is that, while the email is sent successfully, I'm also recieving messages in the inbox of the email address which owns the MCC account along the lines of
Delivery to the following recipient failed permanently:
MCC_account#example.com
Technical details of permanent failure: The email account that you
tried to reach does not exist. Please try double-checking the
recipient's email address for typos or unnecessary spaces.
with the 'Original Message' appended below that indicating it is indeed the message the Script has sent. Here's my code:
function main() {
var accountSelector = MccApp.accounts();
var accountIterator = accountSelector.withIds('###-###-###').get();
if(accountIterator.hasNext()){
var account = accountIterator.next();
MccApp.select(account);
var data = getData();
sendEmail(data);
} else Logger.log("Error: no accounts found");
}
function sendEmail(data){
var name = 'name';
var bodytext = 'body';
MailApp.sendEmail({
to: 'receiver-inbox#example.com',
name: 'Google Adwords Scripts',
replyTo: 'do-not-reply#example.com',
subject: 'SUBJECT',
attachments: [{fileName: name, mimeType: 'text/csv', content: data}],
body: bodytext
});
}
So, to clarify, the MCC account is owned by one email address, the script doesn't reference that at all, but I'm recieving the email not only in the target mailbox but also a failed delivery message in the owner inbox.
Can anyone shed any light on what is happening here?
It is very likely that you are running another copy of the script that is sending these emails. Go to your Google Account settings here and revoke access to the other script.
If you have multiple Google accounts, do a scan for all the accounts.
Okay, apparently this is a known issue with AdWords Scripts:
https://groups.google.com/forum/#!topic/adwords-scripts/SJtNW_wuArI

Microsoft.Exchange.WebServices.Data.ServiceResponseException: When Sending Emails

I am using EWS Managed API to send email.
I am getting a Microsoft.Exchange.WebServices.Data.ServiceResponseException: EmailAddress or ItemId must be included in the request.
In the Soap return XML I see ErrorMissingInformationEmailAddress : This error occurs if the EmailAddress (NonEmptyStringType) element is missing.
Which email address is it talking about?
Using Exchange 2007 SP1.
Exchange credentials are correct and the to/from email addresses are valid emails.
Any ideas? Google has not helped.
Same code has worked for other Exchange Servers.
service.AutodiscoverUrl() does not work for this server.
using Microsoft.Exchange.WebServices.Data;
protected void SendEwsMail()
{
//Trust all certificates
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("user#domain.com", "password");
service.Url = new Uri("Url");
var email = new EmailMessage(service);
email.ToRecipients.Add("user#domain.com");
email.From = new EmailAddress("user#domain.com");
//email.ReplyTo.Add(recipient.FromAddress);
email.Sender = new EmailAddress("user#domain.com");
email.Subject = "test";
// Send the message and save a copy.
email.SendAndSaveCopy();
}
It turns out that for the mail Server (MS Exchange) in question I needed to use this method:
Writing an encrypted mail via Exchange Web Services
var item = new EmailMessage(service);
item.MimeContent = new MimeContent(Encoding.ASCII.HeaderName, content);
// Set recipient infos, etc.
item.Send();
It seems to be because of the encrypyed MIME attachment. Using the standard To, From, Subject properties of the Microsoft.Exchange.WebServices.Data.EmailMessage class does not work correctly.
Although it does work as expected when the mail server was SmarterMail.
SmarterMail 9.x is one of the only mail servers (including Microsoft Exchange) to support Exchange Web Services (EWS).
(from http://blogs.smartertools.com/tag/exchange-web-services/)
Anyone know why SmarterMail would behave differently to MS Exchange?

Twitter4J - 401:Authentication credentials were missing or incorrect [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm playing around with the Twitter4J API and am getting the 401:Authentication credentials were missing or incorrect when using the createFriendship method.
I obtain an instance of Twitter as follows:
protected Twitter getApi(String consumerKey, String consumerSecret, String accessToken, String secret) {
AccessToken token = new AccessToken(accessToken, secret);
return new TwitterFactory().getOAuthAuthorizedInstance(consumerKey, consumerSecret, token);
}
Once obtained I can successfully use the updateStatus method to tweet something. However when I try to execute the createFriendship method I get the following error even though the status updates are working fine
Request processing failed; nested
exception is 401:Authentication
credentials were missing or incorrect.
{"request":"\/1\/friendships\/create.json?screen_name=[user]","error":"Incorrect
signature"}
TwitterException{exceptionCode=[564a75a9-01c7e75c],
statusCode=401, retryAfter=0,
rateLimitStatus=null, version=2.1.5}
In the above error the screen_name=[user] the [user] section is replaced with the correct Twitter screen name.
Is there something I am missing?
Thank you
Sorry it was a simple problem with 2 different versions of Twitter4J on the classpath!