Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    38

    Unanswered: Sending a report in email!

    Ok So I know that you can use sendmail to send a report via email and even make it a snapshot file (which I like)
    like so

    Code:
        DoCmd.SendObject acReport, stDocName, "Snapshot", EmailAddress, , , SubjectLine, _
    "Please log this call and return details to sender." & vbCrLf & vbCrLf & "Internal Reference: ", True
    but I wanted it to automate the process so that the user only clicks the button to send the email and it sends it to the right person based on the tables in the form! where I am having the trouble is attaching the report snapshot without creating a file on the hdd! here is what I have in code

    Code:
        Dim strText As String
        Dim SubjectLine As String
        Dim EmailAddress As String
        Dim Msg, Style, Title, Response
        Dim FName As String
        Dim LName As String
        Dim Intials As String
        Dim stDocName As String
    
        Dim olApp As Outlook.Application
        Dim olMail As MailItem
    
        Set olApp = New Outlook.Application
        Set olMail = olApp.CreateItem(olMailItem)
    
        stDocName = "Mandatory_Helpdesk_Report"
           
        FName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_First_Name]
        LName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_Last_Name]
        Initials = [Forms]![Mandatory_Skills_Helpdesk]![Initials]
        EmailAddress = [Forms]![Mandatory_Skills_Helpdesk]![Email] & "@email.ca"
    
        Msg = "Do you want to email " & Initials & "'s Review to " & EmailAddress & "?"
        Style = vbYesNo + vbDefaultButton2
        Title = "Email Confirmation"
        Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then
    
        With olMail
    
    .To = EmailAddress 'Could also be anyone@hotmail.com
    '.CC = CCEmailAddress
    .Subject = FName & " " & LName & " QA Review."
    .Body = "The Following Attached file is " & FName & " " & LName & " Review!" & vbCrLf & _
    "If you have any Questions or concerns!" & vbCrLf & _
    "Please Contact QA Department for more information regarding this review!"
    .Attachments.Add stDocName
    '.Attachments.Add "c:\My Documents\book.doc"
    .ReadReceiptRequested = False
    .NoAging = True
    .Display 'shows the email on the screen
    '.PrintOut
    .Send
    
    End With
    
        Set olMail = Nothing
        Set olApp = Nothing
    
    End If
    anythoughts?

  2. #2
    Join Date
    Jan 2004
    Posts
    38
    test

  3. #3
    Join Date
    Jan 2004
    Posts
    38

    Re: Sending a report in email!

    Originally posted by Crash1hd
    Ok So I know that you can use sendmail to send a report via email and even make it a snapshot file (which I like)
    like so

    Code:
        DoCmd.SendObject acReport, stDocName, "Snapshot", EmailAddress, , , SubjectLine, _
    "Please log this call and return details to sender." & vbCrLf & vbCrLf & "Internal Reference: ", True
    but I wanted it to automate the process so that the user only clicks the button to send the email and it sends it to the right person based on the tables in the form! where I am having the trouble is attaching the report snapshot without creating a file on the hdd! here is what I have in code

    Code:
        Dim strText As String
        Dim SubjectLine As String
        Dim EmailAddress As String
        Dim Msg, Style, Title, Response
        Dim FName As String
        Dim LName As String
        Dim Intials As String
        Dim stDocName As String
    
        Dim olApp As Outlook.Application
        Dim olMail As MailItem
    
        Set olApp = New Outlook.Application
        Set olMail = olApp.CreateItem(olMailItem)
    
        stDocName = "Mandatory_Helpdesk_Report"
           
        FName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_First_Name]
        LName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_Last_Name]
        Initials = [Forms]![Mandatory_Skills_Helpdesk]![Initials]
        EmailAddress = [Forms]![Mandatory_Skills_Helpdesk]![Email] & "@email.ca"
    
        Msg = "Do you want to email " & Initials & "'s Review to " & EmailAddress & "?"
        Style = vbYesNo + vbDefaultButton2
        Title = "Email Confirmation"
        Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then
    
        With olMail
    
    .To = EmailAddress 'Could also be anyone@hotmail.com
    '.CC = CCEmailAddress
    .Subject = FName & " " & LName & " QA Review."
    .Body = "The Following Attached file is " & FName & " " & LName & " Review!" & vbCrLf & _
    "If you have any Questions or concerns!" & vbCrLf & _
    "Please Contact QA Department for more information regarding this review!"
    .Attachments.Add stDocName
    '.Attachments.Add "c:\My Documents\book.doc"
    .ReadReceiptRequested = False
    .NoAging = True
    .Display 'shows the email on the screen
    '.PrintOut
    .Send
    
    End With
    
        Set olMail = Nothing
        Set olApp = Nothing
    
    End If
    anythoughts?

  4. #4
    Join Date
    Jan 2004
    Posts
    38

    Attn! Moderators! Please delete this thred! I cant!

    I am not sure why this is not working very well here is the code again

    Dim strText As String
    Dim SubjectLine As String
    Dim EmailAddress As String
    Dim Msg, Style, Title, Response
    Dim FName As String
    Dim LName As String
    Dim Intials As String
    Dim stDocName As String

    Dim olApp As Outlook.Application
    Dim olMail As MailItem

    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

    stDocName = "Mandatory_Helpdesk_Report"

    FName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_First_Name]
    LName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_Last_Name]
    Initials = [Forms]![Mandatory_Skills_Helpdesk]![Initials]
    EmailAddress = [Forms]![Mandatory_Skills_Helpdesk]![Email] & "@email.ca"

    Msg = "Do you want to email " & Initials & "'s Review to " & EmailAddress & "?"
    Style = vbYesNo + vbDefaultButton2
    Title = "Email Confirmation"
    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then

    With olMail

    .To = EmailAddress 'Could also be anyone@hotmail.com
    '.CC = CCEmailAddress
    .Subject = FName & " " & LName & " QA Review."
    .Body = "The Following Attached file is " & FName & " " & LName & " Review!" & vbCrLf & _
    "If you have any Questions or concerns!" & vbCrLf & _
    "Please Contact QA Department for more information regarding this review!"
    '.Attachments.Add stDocName
    '.Attachments.Add "c:\My Documents\book.doc"
    .ReadReceiptRequested = False
    .NoAging = True
    .Display 'shows the email on the screen
    '.PrintOut
    .Send

    'DoCmd.SendObject acReport, stDocName
    'DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", EmailAddress, , , SubjectLine, _
    "Please log this call and return details to sender." & vbCrLf & vbCrLf & "Internal Reference: ", True

    End With

    Set olMail = Nothing
    Set olApp = Nothing

    End If
    Last edited by Crash1hd; 02-22-04 at 23:43.

Posting Permissions

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