Results 1 to 4 of 4
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Prompt User To Type Email Addresses


    Hi Guys

    Code:
    Dim oApp As New Outlook.ApplicationDim oEmail As Outlook.MailItem
    Dim fileName As String, todayDate As String
    Dim Date1 As String
    Dim Date2 As String
    
    
    Date1 = Format(Text10, "DD-MM-YYYY")
    Date2 = Format(Text12, "DD-MM-YYYY")
    'Export report in same folder as db with date stamp
    todayDate = Format(Date, "MMDDYYYY")
    fileName = Application.CurrentProject.Path & "\Performances From " & Date1 & " To " & Date2 & ".pdf"
    DoCmd.OutputTo acReport, "Performances", acFormatPDF, fileName, False
    
    
    'Email the results of the report generated
    Set oEmail = oApp.CreateItem(olMailItem)
    With oEmail
        .Recipients.Add "user@gmail.com"
        .Subject = "Lecturer Performances From " & Date1 & " To " & Date2
        .Body = "Dear Staff Members" & vbNewLine & "I here with attach the performane report of lecturers from " & Date1 & " to " & Date2
        .Attachments.Add fileName
        .Send
    End With
    
    
    MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"

    I am using above code to send automated email upon a button click. as you can see here i have hardcoded the receivers email address ".Recipients.Add "user@gmail.com", instead of hardcoding the email is there is a way give the user a prompt to type the email addresses?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You could use an InputBox or textbox. I'd probably display the email rather than send it and let them type it in there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi

    how can put a Inputbox for the above code?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    That would be my third option, but you'd set a string variable to the InputBox and the use the variable for the To.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 7
    Last Post: 08-01-2017, 06:38 PM
  2. Replies: 5
    Last Post: 03-23-2017, 06:38 AM
  3. Send email using CDO, get email addresses from table
    By marvinac1 in forum Programming
    Replies: 3
    Last Post: 12-22-2014, 12:54 PM
  4. Replies: 3
    Last Post: 08-16-2013, 04:15 PM
  5. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09: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