Originally Posted by
CJ_London
So take a look at the link I provided - you should have a property let statement in your class module. And a property get to return the value if required
Code:
Option Compare Database
Option Explicit
Public WithEvents itm As Outlook.MailItem
private strDoc As String
property let strdocumentation(s as string)
strDoc=s
end property
Private Sub itm_Close(Cancel As Boolean)
Dim blnSent As Boolean
On Error Resume Next
blnSent = itm.Sent
If Err.Number = 0 Then
Else
Forms!frmComplaints.FollowUp = Date & ": " & strDocumentation
End If
End Sub
then to assign the value you just have
oDocumentation.strDocumentation = Nz(DLookup("Documentation", "tblTemplates", sTemplate), "")
However I don't see what you are trying to accomplish by using a class object, at the moment there is nothing there that says you need a class object, all can be achieved in a standard module. If you are trying to learn how to use class objects, recommend you read up on the basics first.
Okay I followed your instructions and it is still not populating the DLookUp. Perhaps I misinterepted though. Below are below codes with changes in red
Class Module:
Code:
Public WithEvents itm As Outlook.MailItem
Private strDoc As String
Property Let strdocumentation(s As String)
strDoc = s
End Property
Private Sub itm_Close(Cancel As Boolean)
Dim blnSent As Boolean
On Error Resume Next
blnSent = itm.Sent
If Err.Number = 0 Then
Else
Forms!frmComplaints.FollowUp = Date & ": " & strDocumentation
End If
End Sub
Module:
Code:
Dim OutApp As Outlook.ApplicationDim itmevt As New CMailItemEvents
Dim oDocumentation As New CMailItemEvents
Public Sub EmailTemplate(sTemplate As String, sTo As String, sCC As String, sBCC As String)
Dim OutMail As Outlook.MailItem
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
Set OutApp = New Outlook.Application
'If OutApp Is Nothing Then Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem)
Set itmevt.itm = OutMail
oDocumentation.strDocumentation = Nz(DLookup("Documentation", "tblTemplates", sTemplate), "")
With OutMail
.BodyFormat = olFormatHTML
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = "Email Report"
.HTMLBody = ""
.Display
End With
Set OutMail = Nothing
End Sub