I have created a profile to send an email using CDO 1.21 and MS Outlook Exchange.
The code works fine to send the email from the created profile.
However, it doesn't always work! Every so often, it fails and a mail is returned from the system administrator saying 'undeliverable', 'The originator does not have permission to submit message'.
This is the code I am using:
Dim oSession As MAPI.Session
Dim MsgNew As MAPI.Message
Dim Recip As MAPI.Recipient
On Error GoTo Err_Handler
Set oSession = CreateObject("mapi.session")
oSession.Logon "My Mail Profile", , False, True, 0, False
' Create new message.
Set MsgNew = oSession.Outbox.Messages.Add
' Set message sender.
Set MsgNew.Sender = oSession.CurrentUser
' Set message recipient.
Set Recip = MsgNew.Recipients.Add("email@example.com", , CdoTo)
' Set other message properties and send.
.Text = MessageText
Set MsgNew = Nothing
Set Recip = Nothing
Set oSession = Nothing
Any help would be greatly appreciated.