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

    Unanswered: Sending a report via Email second try

    I am not sure why the last post didnt post properly so mods please delete! but here goes we will try again

    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_Nam
    e]
    LName = [Forms]![Mandatory_Skills_Helpdesk]![Emp_Last_Name
    ]
    Initials = [Forms]![Mandatory_Skills_Helpdesk]![Initials]
    EmailAddress = [Forms]![Mandatory_Skills_Helpdesk]!
    Style = vbYesNo + vbDefaultButton2
    Title = "Email Confirmation"
    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then

    With olMail

    .To = EmailAddress 'Could also be [email]anyone@hotmail.com"> & "@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 [email]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
    ------------------------------------------------------------------------------------

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    I don't think that is possible not to create the file on the hdd. Why not create it in the windows temp dir?

    How is your new code any more 'automated' than using the DoCmd.SendObject method?

  3. #3
    Join Date
    Jan 2004
    Posts
    38
    Well useing the docmd.sendobj the user has to still click send on the email! I wanted them to click a button and have it autosend in the background!
    Last edited by Crash1hd; 02-22-04 at 22:19.

  4. #4
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    Change the edit property to False
    ..."Internal Reference: ", False


    If I am not mistaken - you still have to deal with the Outlook security updates that warn you of a message being sent. I think that you have that in either case.

    Matt

  5. #5
    Join Date
    Jan 2004
    Posts
    38
    Yes you have to deal with the security not a big deal they have to click yes twice but I what I was looking for was attaching the report without having to save it locally first however it sounds like I cant so I have created a script that saves the report sends the email and then deletes the report after email has been sent! Now if only there was a way to get around having that security thing come up but still have it active for other 3rd party programs!

  6. #6
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    >however it sounds like I cant

    You don't have to using the DoCmd.SendObject method (see previous post)......but you have solved your problem and also have more flexibility using Outlook.

  7. #7
    Join Date
    Jan 2004
    Posts
    38
    Thankyou for the help

Posting Permissions

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