Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Houston, TX
    Posts
    3

    Unanswered: Access N00b Question

    I have one quick question..

    I created an address book database using Access...and now I need to email directly out of Access via Outlook.

    Can this be done? Please help..

    Are there any other ways other than importing the whole DB into outlook?


    Any input will be greatly appreciated!

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    Try using SendObject:

    docmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

    Here is an example:

    DoCmd.SendObject acSendReport, "PersonnelRptEMail", "SnapshotFormat(*.snp)", _
    rs!EMail, "", "", "This is a test", "", False, ""

    Help in Access 2003 says that you can use acFormatSNP instead of "SnapshotFormat(*.snp)", but I have not yet tried that.

  3. #3
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    Since HoustonGal asked for more help...
    Create a form for the address book table
    create a button on that form
    put the code from my previous into the OnClick event of the command button
    Change my code to reflect your report name, output type, and email address. You can probably use the email address from the form.

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8

    Try This

    Taken From Microsoft Auto97 help file.

    copy this into a module
    Code:
    Sub SendMessage(Too As String, Subject As String, Body As String, Optional AttachmentPath)
        Dim objOutlook As Outlook.Application
        Dim objOutlookMsg As Outlook.MailItem
        Dim objOutlookRecip As Outlook.Recipient
        Dim objOutlookAttach As Outlook.Attachment
        Dim DisplayMsg As Boolean
        DisplayMsg = False
        ' Create the Outlook session.
        Set objOutlook = CreateObject("Outlook.Application")
        
        ' Create the message.
    
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
        
        With objOutlookMsg
             ' Add the To recipient(s) to the message.
             Set objOutlookRecip = .Recipients.Add(Too)
             objOutlookRecip.Type = olTo
            
             ' Add the CC recipient(s) to the message.
             'Set objOutlookRecip = .Recipients.Add("Michael Suyama")
             'objOutlookRecip.Type = olCC
            
            ' Add the BCC recipient(s) to the message.
    
             'Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
             'objOutlookRecip.Type = olBCC
            
            ' Set the Subject, Body, and Importance of the message.
            .Subject = Subject
            .Body = Body & vbNewLine & vbNewLine
            .Importance = olImportanceHigh  'High importance
            
            ' Add attachments to the message.
            If Not IsMissing(AttachmentPath) Then
    
                Set objOutlookAttach = .Attachments.Add(AttachmentPath)
            End If
            
            ' Resolve each Recipient's name.
            For Each objOutlookRecip In .Recipients
                objOutlookRecip.Resolve
            Next
            
            ' Should we display the message before sending?
            If DisplayMsg Then
                .Display
            Else
                .Send
            End If
    
        End With
        Set objOutlook = Nothing
    End Sub
    then
    in the form you can
    Code:
    Private Sub Command0_Click()
                      Call SendMessage(Me.txtEmail, Me.Subject, "Please pay your the Bill")
    End Sub
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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