pamela rizk
asked on
office 365 sending email
hi
I am having the below problem while sending email: in office 365
here are the server response was: 5.2.0 STOREDRV.Submission.Except ion:
SendAsDeniedException.Mapi ExceptionS endAsDenie d; Failed to process
message due to a permanent exception with message Cannot submit message.
below is the code i am using:
I am having the below problem while sending email: in office 365
here are the server response was: 5.2.0 STOREDRV.Submission.Except
SendAsDeniedException.Mapi
message due to a permanent exception with message Cannot submit message.
below is the code i am using:
FromEmail = "xxx@domain.com"
ToEmail = "x1x1x1@domain.com"
CCEmail = "x2x2x2@domain.com"
Dim msg As String = ""
msg = "Test Sending Email has been Done successfully"
Dim mMailMessage As New MailMessage()
Dim EmailSubject As String = "Test Done System"
Dim EngineStep As String = "Sending External Email"
Dim EmailMsg As String = ""
Dim BodyEmail As String = ""
Dim smtpmail As String = "smtp.office365.com"
Dim UserName As String = "x3x3x3@domain.com"
Dim accPassword As String = "@rabrePR2018"
mMailMessage.From = New MailAddress(FromEmail) '** Set the sender address of the mail message
mMailMessage.To.Add(New MailAddress(ToEmail)) '** Set the recepient address of the mail message
mMailMessage.CC.Add(New MailAddress(CCEmail))
mMailMessage.Subject = EmailSubject '** Set the subject of the mail message
mMailMessage.Body = BodyEmail ' Set the body of the mail message
mMailMessage.IsBodyHtml = True '** Set the format of the mail message body as HTML
mMailMessage.Priority = MailPriority.Normal '** Set the priority of the mail message to normal
Dim mSmtpClient As New SmtpClient(smtpmail) '** Instantiate a new instance of SmtpClient
Dim basicAuthenticationInfo As _
New System.Net.NetworkCredential(UserName, accPassword)
mSmtpClient.Host = smtpmail
mSmtpClient.UseDefaultCredentials = False
mSmtpClient.Credentials = basicAuthenticationInfo
Dim timeout As Integer = 10
mSmtpClient.Timeout = timeout * 1000 'in milliseconds
mSmtpClient.Port = 25
mSmtpClient.EnableSsl = True
Try
mSmtpClient.Send(mMailMessage)
Catch objException As Exception
msg = objException.Message
End Try
mMailMessage.Dispose()
mMailMessage = Nothing
mSmtpClient = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help.
ASKER