Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

How to request read receipt using CDO Email in Excel VBA?

$
0
0

When composing an email using the Gmail email service there's an option to request read receipt.

Is it possible to request it when creating an email using the CDO library?

I tried sending an email from and to myself with Fields(CDO.CdoMailHeader.cdoReturnReceiptTo) = From but the email sent didn't requested read receipt.

Excel VBA code in a module:

' VBA project name:
' VBAProject

' Microsoft Excel 2013 built-in references:
' Excel - Microsoft Excel 15.0 Object Library
' VBA - Visual Basic For Applications

' Aditional references:
' ADODB - Microsoft ActiveX Data Objects 6.1 Library
' CDO - Microsoft CDO for Windows 2000 Library

Option Explicit

Private Sub SendMail( _
  ByVal ConnectionTimeout As Long, _
  ByVal Server As String, _
  ByVal Port As Long, _
  ByVal UseSSL As Boolean, _
  ByVal From As String, _
  ByVal MessageTo As String, _
  ByVal Subject As String, _
  ByVal UseHTML As Boolean, _
  ByVal HTMLBody As String, _
  ByVal TextBody As String)

  Dim Message As CDO.Message
  Dim Configuration As CDO.Configuration
  Dim Fields As ADODB.Fields

  Set Message = New CDO.Message
  Set Configuration = Message.Configuration
  Set Fields = Configuration.Fields

  Fields(CDO.CdoConfiguration.cdoSendUsingMethod) = CDO.CdoSendUsing.cdoSendUsingPort
  Fields(CDO.CdoConfiguration.cdoSMTPAuthenticate) = CDO.CdoProtocolsAuthentication.cdoBasic
  Fields(CDO.CdoConfiguration.cdoSMTPConnectionTimeout) = ConnectionTimeout
  Fields(CDO.CdoConfiguration.cdoSMTPServer) = Server
  Fields(CDO.CdoConfiguration.cdoSMTPServerPort) = Port
  Fields(CDO.CdoConfiguration.cdoSMTPUseSSL) = UseSSL
  Fields.Update

  Message.BodyPart.Charset = CDO.CdoCharset.cdoUTF_8
  Message.From = From
  Message.To = MessageTo
  Message.Subject = Subject
  If UseHTML Then
    Message.HTMLBody = HTMLBody
  Else
    Message.TextBody = TextBody
  End If
  Message.Send

End Sub

Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>