gojets1721
Registered User.
- Local time
- Yesterday, 18:44
- Joined
- Jun 11, 2019
- Messages
- 430
Related to this post
I have a class module and a module to automate Outlook. The module is the code to send the email and the class determines if the email was actually sent. I'm trying to declare a variable in the module in order to update a form field if the email was sent.
Here is the class:
	
	
	
		
Here is the module:
	
	
	
		
I have just a simple "hello" in the module line for testing. However, when I execute the module code and send an email, I can't get the form field to update with the strDocumentation. Only the date appears
Any suggestions on what I'm doing wrong?
Thanks
 I have a class module and a module to automate Outlook. The module is the code to send the email and the class determines if the email was actually sent. I'm trying to declare a variable in the module in order to update a form field if the email was sent.
Here is the class:
		Code:
	
	
	Public WithEvents itm As Outlook.MailItem
Public strDocumentation As String
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 SubHere is the module:
		Code:
	
	
	Dim OutApp As Outlook.Application
Dim itmevt As New CMailItemEvents
Dim oDocumentation As New CMailItemEvents
Public Sub EmailTemplate(sEmailTemplate As String, sTo As String, sCC As String, sBCC As String, sSubjectCap As String, sReportName As String, sCriteria As String, sFileName As String)
        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 = "Hello"
      
        With OutMail
            .BodyFormat = olFormatHTML
            .To = sTo
            .CC = sCC
            .BCC = sBCC
            .Subject = Nz(DLookup("Subject", "tblEmailTemplates", sEmailTemplate), "") & sSubjectCap
            .HTMLBody = Nz(DLookup("Message", "tblEmailTemplates", sEmailTemplate), "")
            If Not IsMissing(sFullNamePath) Then
               .Attachments.Add (sFullNamePath)
            End If
            .Display
        End With
      
        Set OutMail = Nothing
  
    End If
  
End SubI have just a simple "hello" in the module line for testing. However, when I execute the module code and send an email, I can't get the form field to update with the strDocumentation. Only the date appears
Any suggestions on what I'm doing wrong?
Thanks
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	 
 
		 
 
		 
 
		 
 
		 
 
		