Results 1 to 5 of 5
  1. #1
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82

    Determining if an email was sent or not

    Hi all



    I am very close in getting this to work. I need your help to get it over the line.

    An email is created and is opened for edditing to the user. I want to be able to tell access if the user then sends the email or discards it. Having researched this I found the below snippets of code which look great. Unfortunately it is not quite working. The emial is created correctly but upon either sending/discarding nothing happens. I dont get a msgbox (which I am expecting). Any help is much appreciated.

    Here is the class module called "itmevt"

    Code:
    Option Compare Database
    Option Explicit
    Public WithEvents itm As Outlook.MailItem
    Private Sub itm_Send(Cancel As Boolean)
       Dim blnSent As Boolean
       On Error Resume Next
       blnSent = itm.Sent
       If Err.Number = 0 Then
          MsgBox ("NO!")
       Else
          MsgBox ("YES!")
        End If
    End Sub
    Here is the procedure that calls the

    Code:
    Option Compare Database
    Private Sub Command0_Click()
        Dim outlookObj As Outlook.Application
        Dim itmevt As New itmevt
        
        Set outlookObj = New Outlook.Application
        Set itmevt.itm = Outlook.Application.CreateItem(0)
        With itmevt.itm
            .BodyFormat = olFormatHTML
            .To = "craig.o'neill@boi.com"
            .CC = "craig.o'neill@boi.com"
            .Subject = "Test email subject line"
            .Display
        End With
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You may want to change it to use SendObject to trap the cancel. See https://www.accessforums.net/showthread.php?t=62517

  3. #3
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82
    I need to format the email as html so the SendObject command will not work for this situation.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

  5. #5
    craig1988 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2014
    Posts
    82
    Hi

    Taken from the end of the link.

    Code:
    Limitations of the SendObject Command
    Code:
    While the SendObject command is useful for sending an object or short message, it has several significant limitations:
    
    Messages must be 255 characters or less Limitations of the SendObject Command
    While the SendObject command is useful for sending an object or short message, it has several significant limitations:
    


    I have ligitimate reasons why I am using outlook.application

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Determining a files extension?
    By baronqueefington in forum Programming
    Replies: 8
    Last Post: 05-06-2015, 10:26 AM
  2. Determining a Control's Subscript
    By The Professor in forum Forms
    Replies: 1
    Last Post: 12-13-2012, 08:56 AM
  3. Determining the value of 3 Date/Time Boxes....Newbie
    By REAbernathy in forum Programming
    Replies: 3
    Last Post: 09-12-2012, 12:05 PM
  4. Determining cause of Update event
    By RJosephNewton in forum Access
    Replies: 3
    Last Post: 03-25-2010, 04:34 PM
  5. Determining Winners/Losers
    By pfeff in forum Queries
    Replies: 0
    Last Post: 02-21-2008, 03:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums