Link to home
Start Free TrialLog in
Avatar of pamela rizk
pamela rizkFlag for Lebanon

asked on

office 365 sending email

I am having the below problem while sending email: in office 365
here are 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.
below is the code i am using:
FromEmail = ""
        ToEmail = ""
        CCEmail = ""
        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 = ""
        Dim UserName As String = ""
        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
        Catch objException As Exception
            msg = objException.Message
        End Try
        mMailMessage = Nothing
        mSmtpClient = Nothing

Open in new window

Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pamela rizk


ohh yes you are right i think this is the problem thnak you
Glad I could help.