1

I am currently using CDO to send e-mails from Access with VBA using SMTP and it works fine.

My problem is when I use SMTP I do not see the sent e-mails in the sent items in the mailbox that I am using. I need this so I can proof to the recipient that the e-mail was indeed sent. Does anyone one have an idea how I can fix this? Any solution in VB.NET, C#, VBScript or VBA (as above) will be welcome. Below is my script in VBA.

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

Set objmsg = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds

  ''http://schemas.microsoft.com/cdo/configuration/ the .Items must pe prefixed with this

  .Item("sendusing'") = cdoSendUsingPort
  .Item("smtpserver'") = "1.1.1.1"
  .Item("smtpauthenticate") = cdoBasic
  .Item("sendusername") = Username
  .Item("sendpassword") = Password
  .Item("smtpserverport") = 25
.Update
End With

strbody = "Message here"

With objmsg
  Set .Configuration = objConf
  .To = "email@domain.com"
  .From = "me@domain.com"
  .Subject = "EmailSubject"
  .HTMLBody = strBody
  .AddAttachment myfile
  .Fields("urn:schemas:mailheader:disposition-notification-to") = "me@domain.com"
  .DSNOptions = cdoDSNSuccessFailOrDelay
  .Fields.Update
  .Send
  If Err.Number <> 0 Then
    Debug.Print Err.Description
  End If
  • 1
    Look in the smtp server logs – DavidPostill Jan 30 '17 at 14:05
  • Yes David, I know about that but I do not have easy access to it because the whole company's emails are in there and they won't give me access to that. Therefore I want it in my sent items. – Manie Verster Feb 1 '17 at 6:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.