question

LuayAlmamury-9476 avatar image
0 Votes"
LuayAlmamury-9476 asked LuayAlmamury-9476 commented

ExchangeService eService

I'm using ExchangeService eService = new ExchangeService(ExchangeVersion.Exchange2010_SP1); and when I tried to changed email from that different what its trusted from server like : EmailMessage emailMessage = new EmailMessage(eService); emailMessage.From = Email_From; // here i got the error The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account. Cannot submit message How I can add new email so I can use it in exchnageServer ?

office-exchange-server-administration
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @LuayAlmamury-9476 ,

Are you using the EWS Managed API 2.0 to send emails? If not, please tell me more about it.
Please check the user you're using has the Send On Behalf/Send As permission:

https://docs.microsoft.com/en-us/exchange/recipients/mailbox-permissions?view=exchserver-2019#use-the-exchange-management-shell-to-assign-the-send-as-permission-to-mailboxes-and-groups

Regards,
Lou


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·

I'm using
ExchangeService eService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

0 Votes 0 ·

And How I can do on behalf of using C# programming language. I don't have permission to access as admin to make any change.

0 Votes 0 ·

Hi @LuayAlmamury-9476 ,

Good day!

Could you provide more info of this question?
Do you mean you are using the API or other scripts?
If so, there could be some codes that referring to [Autodiscover, logon, credential], please found them and check the Logon name and password is right.

Get started with EWS Managed API client applications

Sorry I don't know much about C# and these codes, but I would think you can check the permissions.

Regards,
Lou

0 Votes 0 ·

That's my code
\ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new WebCredentials("EmailSender", "Password");
string serviceUrl = "https://outlook.office365.com/ews/exchange.asmx";
service.Url = new Uri(serviceUrl);
EmailMessage emailMsg = new EmailMessage(service);
emailMsg.From = currentUser.Email; //This email is different from Credential email
emailMsg.Subject = mailSubject;
emailMsg.Body = mailBody;

           emailMsg.SendAndSaveCopy();

The thing is that the Credential account is different from current user email. The users don't login in the domain so I have no access to their credential. So I want to use an account to send email instead of the users.It was possible to send email even without credential when we were using Exchange server but in office 365 I get this error:

0 Votes 0 ·

Hi @LuayAlmamury-9476 ,

Thanks for sharing these info.
I've seen some similar issues about Exchange Online and EWS Managed API. And they couldn't logon with Account + Password.

78136-image.png
I'm afraid this is it and also what we don't wanna see. Upcoming changes to Exchange Web Services (EWS) API for Office 365
Kindly suggest consider the Graph as the plan B.

Regards,
Lou


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·
image.png (35.4 KiB)

This is my problem emailMsg.From = currentUser.Email; //This email is different from Credential email
I an access to the host using usrNmae and password , If I don't use emailMsg.From = currentUser.Email; it will sent email successfully, but when i tried to change to the emailMsg.From = currentUser.Email; I got the error
The user account which was used to submit this request does not have the right
to send mail on behalf of the specified sending account. Cannot submit message
because I'm trying to use something different form what is use in the setting. I don't have access as admin to exchange server to add new user as credit user to sent as new emailMsg.From ="myemail@yahoo.com"; is there any way to do that without having access as admin ?. I mean I want to change or add new user programmatically

0 Votes 0 ·

Hi @LuayAlmamury-9476 ,

Oh so sorry for the misunderstanding above.
If you mean you are trying to sending an email from the CurrentUser but not the account you logon, I would think this credential account should have the Send As/Send on behalf permission.

As you are using the Yahoo account, I'm considering if you could add the permission from the yahoo mailbox side, you could check it first.
Also I will try this but I'm not sure if it's going to work cause I don't know much about Yahoo mailbox..

Regards,
Lou

0 Votes 0 ·
Show more comments

1 Answer

LuayAlmamury-9476 avatar image
0 Votes"
LuayAlmamury-9476 answered ZhengqiLou-MSFT commented

I'm using office 356 and I can't use SentAS or on behalves of because I don't have admin permission to access and change. I want to go around that and using C# to overcome this issue.
I tried to use emailMessage.Sender = "myEmail@yahoo.com"; but it still pointing to the different email in office 356 setup as default email.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @LuayAlmamury-9476 ,

Good day!

Then I would think we're reaching a dead end.
As this cmdlet: emailMessage.Sender = "myEmail@yahoo.com", I think the credential account should has the permissions on this yahoo mailbox. And it seems impossible for Office 365 to do that.

Also I did a research about this, like using Office 365 accounts sending emails as Gmail(since I don't have a yahoo account), and it failed as Microsoft does not support this.

For this issue, I'm afraid I should say no or you can't do that for the yahoo account. If you have an O365 admin account, you could try sending as your Office 365 mailbox.

Best regards,
Zhengqi Lou

0 Votes 0 ·