3

I want to sending email through smtp.office365.com in VB.NET
It work!! when i use "FROM" address same as user authentication

BUT how to send emails using other email address as the FROM address in domain

I try "Mailbox Delegation" set other email address for behalf
BUT it don't work. Please suggest where I'm going wrong.

I am using the following to

Dim myMessage As New System.Net.Mail.MailMessage
Dim myClient As New System.Net.Mail.SmtpClient()

Dim strUserName As String = "john@domain.com"
Dim strPassword As String = "p@ssw0rd"

myClient.Port = 587
myClient.Host = "smtp.office356.com"
myClient.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
myClient.EnableSsl = True

myMessage.From = New System.Net.Mail.MailAddress("marry@domain.com")
myMessage.To.Add(strTo)
myMessage.Subject = "Send E-mail using Office365"
myMessage.Body = "Test Send Email"

myClient.Send(myMessage)
almond
  • 31
  • 2
  • Is there any error message? – Bruce Oct 22 '18 at 11:19
  • Hi @Bruce ,I have error message like this " Transaction failed. The server response was: 5.2.0 STOREDRV.Submission.Exception :SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. ..., 20.52176:140FE2841800101082010000" please suggest. – almond Oct 24 '18 at 04:30
  • I can solved this problem with 'Mailbox Delegation' – almond Nov 02 '18 at 07:39

0 Answers0