SmtpClient, send email through smtp.gmail.com, but From another account - smtp

I wonna send email through gmail smtp, but users should see my corporative "From"
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("igor#dynback.com", "pass", "mail.dynback.com");
I am getting SmtpException:
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required"
I heard its all possible and called "Relay", but I am not sure, do i need to put somehow google credentials?

You'll have to use a Google account for the credentials. You should be able to set the From or ReplyTo address in your MailMessage to whatever you want.

Use "Save As" feature in gmail.

Related

Emails sent through smtp server is not received to educational domain accounts

I am trying to send email using flask_mail that has configuration as:
MAIL_SERVER = "smtp.gmail.com"
MAIL_USERNAME = "dummy#gmail.com"
username is my personal verified gmail account.
The smtp server is able to send emails to #gmail and #xyz.edu accounts as I see no error.
But I cannot see emails in #xyz.edu accounts.
I can see the emails sent to my other #gmail accounts.
I am not sure why I cannot see the emails sent by smtp to my #xyz.edu account.
Any help is appreciated.
Thanks
If you can't telnet from the exchange box to that specific IP/SMTP then the problem could be on their end or on the path to their end.
The problem was with the ISP on the other end.
They need to configure
Exchange to accept mail for multiple authoritative domains.

How to get the email address for the current logged in user in EWS?

What is the correct way of getting a user's email address using EWS SOAP API's if I have the credentials (username & password) and the server address.
What you need is as follow:
Create a AuthenticationContext
Setup a ClientCredential
Use AuthenticationContext to acquire a token
You will have to pass a callback which if the authentication is fine, you will receive AuthenticationResult in onSuccess of AuthenticationCallback
You can get the information from AuthenticationResult.UserInfo.DisplayableId

Set IMAP hostname while sending email using JavamailAPI

I have a IMAP server host name : xyz.com. And my SMTP host name is : comcast.net.
Now when I send emails via Outlook it automatically shows my ID [sender ID] as : myusername#xyz.com and not myusername#comcast.net.
I would like to achieve the same using JavaMail API.
When I use JavaMail API, it shows the sender as myusername#comcast.net. I understand this is the way it works. IMAP for receiving emails and SMTP for sending emails.
However, I would like to develop the behavior similar to that of Outlook where it sets IMAPs server hostname, instead of the SMTP's server hostname, in the sender ID.
Thanks & Regards,
Ravikiran Mane.
I think you're talking about the difference between what you put in the From header of the message (using the setFrom method), and what user name you use when you login to your mail server to send the message (using the connect method). Normally they would be the same. Your mail server may or may not allow you to set a different address in the From header. Some mail servers will require you to verify that the alternate From address is actually your address before they will let you send a message with that in the From header.

How to send email in exchange online (EWS1.1) with shared mail box

I am trying to send an email using Exchange WebServices 1.1 using a shared mail box. I am getting following error.
"This account is locked. Visit https://autodiscover-s.outlook.com/owa/mycompany.com to unlock it."
But if I browse this url, it takes me to admin mail box, then I can change it to visit the shared mail box. Even I can send an email using this mail box from outlook. (All these are already set following a MS article).
My Question is how to send email using these account, as I don't want to make the email personalised and rather keep it from a distribution group/shared mail box.
// Connect to Exchange Web Services as user1 at contoso.com.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials(userName, password);
service.AutodiscoverUrl(userName,
delegate
{
return true;
});
I just want the email should show received from "shared" mail box. How can I achieve this?
Edit :
If I use my personal account all these works fine, I can read emails, send emails and delete emails. But if I changed the credentials to shared mail box, it says the account is locked.
I have administrative and "send as" rights on this shared mail box. At the same time I can send email using outlook as well.
Sanjay

Get logged on user's SMTP address via EWS?

I have a client app written using EWS Managed API 1.1. Here's the situation:
The client does not run on a computer within the same domain as the Exchange Server.
I have the username and password of a user, but not their email address.
There's no commonality between username (e.g. ABC123\001234) and email address (e.g. joe.bloggs#company.com).
I can connect to EWS just fine, send messages, etc.
However my software needs to discover the authenticated user's email address, and for various requirements reasons can't just ask the user to provide it.
I assumed I'd be able to get such a simple detail back from the web service, but I'm stumped!
Is this possible for both 2007 and 2010?
Thanks!
You may be able to do it using ExchangeService.ResolveName. I tried it with the following EWS Managed API code example on Exchange 2007 and it worked like a charm:
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Url = new Uri("https://serv/EWS/exchange.asmx");
service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain");
ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
return true;
};
var resolvedNames = service.ResolveName("001234");
foreach (var resolvedName in resolvedNames)
{
Console.WriteLine(resolvedName.Mailbox.Address);
}