Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    22

    Unanswered: Access to Outlook Code

    I was wondering if it was possible to have a button click event (In Access) where when you click it, it shoots you over to Outlook and Populates the To, From, Subject Lines and possibly attachments? I got it started kind of but I am not sure how to populate the above lines for example I want:

    To: test@test.com
    From: mytest@test.com
    Subject: This is a test

    I am using Access and Outlook 2007 and want VBA Code.

    Dim objOL As Outlook.Application
    Dim objMsg As Outlook.MailItem
    Dim fso As FileSystemObject

    Set fso = New FileSystemObject
    Subjectline$="Test"
    If Subjectline$ = "" Then
    MsgBox "No subject line, no message." & vbNewLine & vbNewLine & _
    "Quitting...", vbCritical, "E-Mail Merger"
    Exit Function
    End If

    BodyFile$="This is a test"
    If BodyFile$ = "" Then
    MsgBox "No Body, no message." & vbNewLine & vbNewLine & _
    "Quitting...", vbCritical, "E-Mail Merger"
    Exit Function
    End If

    But when I run this it says that BodyFile$, and SubjectLine$ isn't recognized at all. Are there other ways of referencing to the Subject and To and From Lines? Loaded question but any help would be appreciated.

  2. #2
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    119
    Here's some code that I've used before:

    Dim oApp As Object, oMessage As MailItem, oRec As Recipient,
    Set oMessage = oApp.CreateItem(olMailItem)
    oMessage.Display
    Set oRec = oMessage.Recipients.Add(test@test.com)
    oRec.Type = olTo
    oMessage.Subject = "This is a SUBJECT test"
    oMessage.Body = "This is a BODYtest"
    Regards
    JD

    Software-Matters

Posting Permissions

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