I try to forward a Message through EWS with the following code:
EmailAddress[] adresses = { "servicedesk#example.com", "allschwil_sox#example.com" };
newEmailMessage.Forward("Account access has been removed according to attached Report", adresses);
example.com beeing our company domain. For some unknown reason, the email is not forwarded to our domain (servicedesk#example.com) but to another company: servicedesk#lifetech.com. Does anyone know how that can happen?
Allschwil_Sox#example.com got sent correctly to allschwil_sox#example.com
Related
I am having an issue with sending emails specifically to Gmail-related accounts, and I'll be darned if I know what the issue is. This is a C# ASP.NET project, by the way.
First, the following code works, as long as I am sending to any email account OTHER than a Gmail account:
var mail = new MailMessage {
Subject = "test email",
Body = "this is only a test",
Priority = MailPriority.High,
IsBodyHtml = true,
From = new MailAddress ( "<outbound email here>" )
};
var msgID = Guid.NewGuid().ToString();
var sentBy="<outbound mail domain>";
mail.Headers.Add ( "message-id", $"<{msgID}>");
mail.Headers.Add ( "msg-id", $"<{msgID}#{sentBy}>");
mail.To.Add ( new MailAddress ( "<recipient email>" ) );
var smtpClient = new SmtpClient("<email server address>") {
Port = 587,
Credentials = new NetworkCredential("<sender's email address>", "<password>"),
};
smtpClient.Send ( mail );
I have removed email addresses and network credentials, obviously.
The code works, because as long as I send email to a NON-Gmail account, it comes through just fine. But anything going to a Gmail-related account never arrives.
I added the two lines in the code above to add a message ID to the header based on what I read in several older posts here about some mail servers, like Gmail, rejecting email messages that didn't include them, but it has not fixed the issue, and I'm out of ideas. My ISP says the SPF record for the mail server is fine, so according to them that's not the issue.
Has anyone else encountered this recently, and if so, how did you fix it?
To clarify, the comments/answers I have received so far are appreciated, but as I stated in the OP, this is a problem with sending emails TO Gmail accounts. I am using my ISP's mail server to send them, and I am adding a message ID to the header to address what the log says, that the message is missing a message ID and won't be accepted. I can send emails to other non Gmail accounts just fine, and when I inspect the headers they show a message id. So I don't know why this continues to be an issue.
So the answer to this is that the issue was related to changes Google made to policies for sending emails to Gmail accounts, which might require adjustments to the SPF record on the sending SMTP server. That was the case in this situation - the hosting company was slow to respond (took them more than a week) and had to elevate the issue to their Tier 3 techs, but once the SPF record was fixed to account for Google's changes, all was resolved.
I am trying to send message from server email to my gmail
WebMail.SmtpServer = "mail.marekjedrysiak.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = true;
WebMail.UserName = "mail#marekjedrysiak.com";
WebMail.Password = "******";
WebMail.From = "mail#marekjedrysiak.com";
WebMail.Send("marekjedrysiak1#gmail.com", "Message from server",null);
then coming this message :
Please help :(
This isn't an ASP.NET or C# related problem, your domain doesn't have an MX record. You can confirm this by checking http://www.mxtoolbox.com.
I see that your domain is registered with Tucows (Hover). In order to change your MX records:
Log in to your Hover account. If you have multiple domain names, select your marekjedrysiak.com domain.
Click the DNS tab.
Click Add New.
For Record Type, select MX.
Enter the address of your mail server.
Click Save.
If you need more help setting up or debugging your mail service, you should contact Hover's support. They can also advise you on what exactly to enter as the address of your mail server.
Source:
https://help.hover.com/hc/en-us/articles/217282457-How-to-Edit-DNS-records-A-CNAME-MX-TXT-and-SRV-Updated-Aug-2015-
I am trying to discover if there is a way to determine the internet message ID after sending an email using the EWS Managed API. I understand you can go in there and get the results from the sent box, but the server that is sending these emails is sending multiple emails at a time from different services.
No you can't, basically because EWS sends message Asynchronously the Id isn't available see https://social.msdn.microsoft.com/Forums/azure/en-US/dd034b8c-ffa1-4ae0-9025-45fcf520c9e5/updateitem-does-not-return-itemid?forum=exchangesvrdevelopment
As a work around you might want to consider setting the Internet messageId on the Message before you send it. As long as it valid and unique it should work okay eg
ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
EmailMessage ema = new EmailMessage(service);
ema.Subject ="test from ews";
ema.Body = new MessageBody("test<br>Rgds<>");
ema.ToRecipients.Add("gscales#domain.com");
ema.SetExtendedProperty(PidTagInternetMessageId,("<" +Guid.NewGuid().ToString() + "#domain.com>"));
ema.SendAndSaveCopy();
Also if you save the message first as a draft before sending it the server will assign the MessageId property which which should then be able to read back using Load.
Cheers
Glen
I need to implement a “email support” section in our application. So email “To” address will be admin#mydomain.com” and from address will be the email address of the end user.(The end users email address may be on the same domain or another domain like user#mydomain.com or user#gmail.com).
In the application I am authenticated the email using admins account details (username and password)
System.Net.NetworkCredential("admin#mydomain.com", adminpassword);
Also I am using host address as “mail.mydomain.com”
Issue is I am getting the following error:
“Mailbox unavailable. The server response was: From address must
match authenticated address” error message.
Is it possible to send an email with the correct sender email address(users from address)
My code sample is
message.To.Add(“admin#mydomain.com”);
message.From = new MailAddress(“test#gmail.com”);
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential(admin#mydomain.com, adminpassword);
smtp.EnableSsl = false;
object usrtkn = message;
smtp.Send(message);
In general the From address shouldn't be the user themselves, it should be an internal system address. This is mainly because the user isn't actually sending the email, the application is. In the email itself you can specify which user sent it (and what their email address is). You can perhaps even specify the user's email address in the ReplyTo field of the message.
But the message you're getting from the SMTP server pretty much says it all. If the message is "from" that user then the SMTP server refuses it because it's sensitive to authentication and origination of emails. To the SMTP server (to any SMTP server I would imagine) it looks like you're trying to spoof messages.
You cannot do what you are doing, because the SMTP server is not allowing you to "impersonate" the user's email address for sending to the system. And thank goodness this is the case or else people would be spamming/spoofing the heck out of everyone under someone else's name.
Why are you trying to have it appear that the user is sending an email to the application? Why not just have a support section of your application where users can "submit" requests for support to the system and then if you want to send emails out to the users, then your scenario will work, but just in reverse (where the system is the From address and the user is the To address).
I use Golang, I skill put the "From" int othe message
msg := []byte(
"From: root#myserver.com.br\r\n" +
"To: destiny#myserver.com\r\n" +
"cc: destiny2#myservercom\r\n" +
"Subject: Why are you not using Mailtrap yet?\r\n"+
"\r\n"+
"Here’s the space for our great sales pitch\r\n")
auth := smtp.PlainAuth("", root, password, host)
err := smtp.SendMail(address, auth, root, destinationEmail, msg)
I'm currently developing an application that handles mail for mailboxes automatically. We use the tool Outlook Redemption and connect with one service account to multiple Exchange mailboxes.
Case
The problem we face is forwarding mail from the original mailbox. Say service account 'A' is handling shared mailbox 'B' and is forwarding mail. I'd like the sender to be the mail address of 'B', but when I receive the mail the mail address of 'A' shows up as sender.
Source code
// Initialize the session with the service account.
_session = new RDOSession();
_session.LogonExchangeMailbox(configurationSettings.MailAddress, configurationSettings.Url);
// Connect to the target mailbox and retrieve mail message.
RDOStore store = _session.Stores.GetSharedMailbox(targetMailBox);
RDOMail originalMailItem = store.GetMessageFromID(entryId);
// Creates a forwarded version of the mail.
RDOMail forwardMailItem = originalMailItem.Forward();
// Set sender to target mailbox owner.
if (store is RDOExchangeMailboxStore)
{
forwardMailItem.Sender = ((RDOExchangeMailboxStore)store).Owner;
forwardMailItem.SenderEmailAddress = targetMailBox;
}
// Set recipient and send.
forwardMailItem.Recipients.Clear();
forwardMailItem.Recipients.Add(forwardMailAddress);
forwardMailItem.Send();
Questions
Anyone got a clue on a solution?
If this won't work, is it possible to get the mail address of 'B' in the 'On behalf of' rule?
Thanks in advance!!
The problem is that the message being forwarded is created in the primary store in the profile, not the delegate mailbox.
Besides setting the Sender property, have you tried to also set the SentOnBehalfOf property?