Consulting

Results 1 to 2 of 2

Thread: Can someone see what is going wrong??

  1. #1
    VBAX Newbie
    Joined
    Apr 2014
    Posts
    3
    Location

    Can someone see what is going wrong??

    I'm trying to compose a mailt with the form information as attachment like you can see in the code below but i keep getting this error, can someone see what i'm doing wrong?


    p1.jpg

    With the following highlited in yellow:

    Set olMail =

    Private Sub Command19_Click()
    
      Set fso = CreateObject("Scripting.FileSystemObject")
    Set olObj = GetObject(, "Outlook.Application")
    Set olMail = olObj.CreateItem(olMailItem)
         
         
         
         
        olMail.Subject = "Training"
        olMail.Importance = "2"
        olMail.To = ""
        olMail.CC = ""
        olMail.BCC = ""
        olMail.HTMLBody = "Here comes the body"
        Email_Subject = "Subject"
        olMail.Display
         
         
         
        On Error GoTo debugs
        Set Mail_Object = CreateObject("Outlook.Application")
        Set Mail_Single = Mail_Object.CreateItem(0)
        With Mail_Single
            .Subject = Email_Subject
            .To = Email_Send_To
            .CC = Email_Cc
            .BCC = Email_Bcc
            .Body = Email_Body
             
            .Send
    'acFormatpdf will export the result of query into pdf format and will add the pdf as attachment
    DoCmd.SendObject acSendForm, “sales_detail”, acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True
    
    End Sub

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,710
    Location
    IF it ain't in the yellow, look before the yellow.


    Is that comma necessary?


    Hint. Always put "Option Explicit" at the top of your code modules. In the VBA editor (the VBA), use the Options Menus to require declarations.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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