Results 1 to 3 of 3
  1. #1
    SteveHale is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    10

    How to add a "Send As" or Send from a different Mailbox

    Hi all,



    Below is the code that i have and it works nicely, however, i would like the option to add a "Send As" or make use of the "From" function in outlook...

    Code:
    Private Sub btn_EmailSW_Click()On Error GoTo ErrorHandler
    
    
    Dim strTempNew As String
    Dim strOld As String
    Dim strTo As String
    Dim strFrom As String
    Dim strSubject As String
    Dim strMessageText As String
    Dim LResponse As Integer
    
    
    strFrom = "mypicked@email.here"
    strTo = ""
    strSubject = ""
    strMessageText = "hi there!"
            vbNewLine & vbNewLine & _
            "Another line here" & _
            vbNewLine & vbNewLine & _
            "Signature here"
        
    DoCmd.OpenReport "my.report", acViewPreview
        
    DoCmd.SendObject ObjectType:=acSendReport, _
    ObjectName:="my.report", _
    OutputFormat:=acFormatPDF, _
    From:=strFrom, _
    To:=strTo, _
    Subject:=strSubject, _
    MESSAGETEXT:=strMessageText, _
    EditMessage:=True
    
    DoCmd.Close acReport, "my.report"
    
    ErrorHandler:
      Select Case Err  'specific Case statements for errors we can anticipate, the "Else" catches any others
        Case 2501       'Action OpenReport was cancelled.
        MsgBox "Ranged Log Inquiry Cancelled"
        
       End Select
    
    DoCmd.Close acReport, "my.report"
    End Sub
    I keep coming across a "Compile Error: Named argument not found" and is aimed at "From:=".

    Any suggestions?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,977
    That would infer there is no from parameter. Have you checked ms for syntax of that command?
    If you want to use outlook, it has the SendUsingAccount option. Again check the options
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,811
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-23-2015, 09:32 PM
  2. Replies: 11
    Last Post: 01-22-2015, 03:31 PM
  3. Replies: 4
    Last Post: 02-13-2014, 02:46 PM
  4. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  5. "Send Email" button on Query-Based Report
    By athyeh in forum Programming
    Replies: 5
    Last Post: 07-05-2013, 12:44 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