Results 1 to 2 of 2
  1. #1
    Join Date
    May 2013
    Posts
    1

    Unanswered: Outlook.Application on Access Database

    I am trying to run this code but the system does not respond to any of the inputs. Could you please help me with this:

    Private Sub SendMail_Click()
    On Error GoTo Err_SendMail_Click
    If Me.Dirty Then
    Me.Dirty = False
    End If
    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
    strTo = GetToLine([GAEFormTaskID])
    strSubject = "GAE FORM TASK REGISTER AUTOMESSAGE: Approval of " & [FormNumberShow]
    strMessageText = GetDataList([GAEFormTaskID])
    If (strTo = "") Or (strMessageText = "") Then
    Exit Sub
    End If
    strMessageText = [FormNumberShow] & " (" & [Title] & ") has been approved, also incorporating approval of the following data:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & strMessageText
    Dim olApp As Object
    Dim olItem As Object
    Set olApp = CreateObject("Outlook.Application")
    Set olItem = olApp.CreateItem(0)
    With olItem
    .To = strTo
    .Subject = strSubject
    .Body = strMessageText
    .Send
    End With
    Set olItem = Nothing
    Set olApp = Nothing
    [Correspondence] = "FROM: " & GetUserNameAndComputerName & Chr(13) & Chr(10) & "TO: " & strTo & Chr(13) & Chr(10) & "SENT: " & Format(Now, "dddd, dd/mm/yyyy @ hh:mm:ss") & Chr(13) & Chr(10) & "SUBJECT: " & strSubject & Chr(13) & Chr(10) & "MESSAGE:" & Chr(13) & Chr(10) & strMessageText
    Exit_SendMail_Click:
    Exit Sub
    Err_SendMail_Click:
    MsgBox "There was an error sending. Check to make sure that Microsoft Outlook is open (or at least minimized to the System Tray) and try again."
    Resume Exit_SendMail_Click
    End Sub

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    put a watch/ breakpoint on the function definition
    then run the code
    when the execution breaks then step through the code
    examine the variables as required

    Its a while since I did any Outlook automation, but shouldn't there be a send method used after you have set the properties
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •