Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    311

    Unanswered: Mailing Excel files from access with VBA

    I have 30 emails i have to send out each week (using outlook)

    I would like to program in the user address' and the name of the files (both email and filenames are constant) and also add a constant subject and msg body.

    I have sent access repts but not such a complete task as the one @ hand.


    Tks

    M~

  2. #2
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Mailing Excel files from access with VBA

    Originally posted by mikezcg
    I have 30 emails i have to send out each week (using outlook)

    I would like to program in the user address' and the name of the files (both email and filenames are constant) and also add a constant subject and msg body.

    I have sent access repts but not such a complete task as the one @ hand.


    Tks

    M~
    I used following code once in Excel.
    I suppose in Access it's quite the same.


    Code:
    Private Sub createEmail()
        Dim myOutlook As Outlook.Application
        Dim myMail As Outlook.MailItem
        Dim myAttachments As Outlook.Attachments
        Dim myDistributionList As AddressEntry
        
        Set myOutlook = CreateObject("Outlook.Application")
        Set myMail = myOutlook.CreateItem(olMailItem)
        Set myAttachments = myMail.Attachments
    
        myAttachments.Add "C:\myExcel-file",olByValue, 1
        
        Set myDistributionList = myOutlook.GetNamespace("MAPI").AddressLists("Contacts").AddressEntries("myRecipientsName")
    
        With myMail
            .To = myDistributionList
            .Subject = "My subject"
            .Send
        End With
        
        Set myOutlook = Nothing
        Set myMail = Nothing
        Set myAttachments = Nothing
        
    End Sub

Posting Permissions

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