Results 1 to 2 of 2
  1. #1
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305

    Suggestions on how to allow Email code edits not via VBA

    Confusing title....I'm sorry. I have the below VBA code attached to a command that exports a report to Outlook and inputs a preset subject line and message. Anything that I want to edit the preset subject or message, I need to directly edit the VBA. Which means everyone needs to exit the DB. It's somewhat of a hassle.



    I was wondering if anyone has any suggestions on how to improve. Perhaps make a table and then reference the table fields in the email VBA? And then edit the table fields whenever I need to update?

    Code:
    Private Sub btnEmailReport_Click()
    On Error GoTo btnEmailReport_Click_Err
    
    
        Dim ReportName As String
        Dim Subject As String
        Dim ToRecipient As String
        Dim CCRecipient As String
        Dim BCCRecipient As String
        Dim Message As String
        
        ReportName = "rptEmailReport"
        Subject = "Email Report"
        ToRecipient = "jsmith@gmail.com" & "; " & "pjohnson@gmail.com
        CCRecipient = ""
        BCCRecipient = ""
        Message = "Hello"
    
    
    btnEmailReport_Click_Exit:
        Exit Sub
    
    
    btnEmailReport_Click_Err:
    
    
        If Err = 2501 Then
    
    
        Else
    
    
        MsgBox "Error #" & Err.Number & " - " & Err.Description, , "RMIS Error"
        
        End If
        
        Resume btnEmailReport_Click_Exit
        
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    NEVER hardcode!
    put all values in a table, this preloads the form, then user can edit the form values (or you can edit the table values)
    then send.

    the table could also store users ID, & their emails.
    then the code could preload based on their login id

    vUser = Environ("Username")
    vUserEmail= Dlookup("[Email],"tUsers","[UserID]='" & vUser & "'") & ""

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

Similar Threads

  1. Edits for email addresses
    By msmithtlh in forum Forms
    Replies: 1
    Last Post: 03-30-2017, 02:12 PM
  2. Help with email code
    By sroot in forum Programming
    Replies: 11
    Last Post: 12-10-2014, 06:46 AM
  3. Replies: 6
    Last Post: 03-26-2014, 10:04 AM
  4. Add picture to my email code
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 09-25-2013, 08:26 AM
  5. smtp email code
    By alyon in forum Access
    Replies: 2
    Last Post: 05-15-2012, 07:42 AM

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