Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 44
  1. #16
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Why do you need to use that method?
    Read receipts...



    They require it.

    I have 3 or more forms doing different tasks and they're all similar, just different reports, dates, or with no pdf report (bliss)

    Most of the time I don't bug you guys for help I try not to but there's some of it I can't get my head around.

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    June, if you want to delete some of my posts to keep this thread on track, please do.

    Ruegen,
    I know you are thinking of creating different FE files for users that do not have Outlook. You can make your declarations in a way that is called late binding. You can avoid referencing the library. You don't have to reference the library and do early binding. Here is an explanation on how to create Outlook objects writing your code without a reference to the library.
    http://social.msdn.microsoft.com/For...orum=accessdev

  3. #18
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    June, if you want to delete some of my posts to keep this thread on track, please do.

    Ruegen,
    I know you are thinking of creating different FE files for users that do not have Outlook. You can make your declarations in a way that is called late binding. You can avoid referencing the library. You don't have to reference the library and do early binding. Here is an explanation on how to create Outlook objects writing your code without a reference to the library.
    http://social.msdn.microsoft.com/For...orum=accessdev
    oh good I like the idea of that!

    so how do I know what objects to include (or make into objects) generally? Is it just a few? (reading the link)

    rephrase- I am making dim into object instead of referencing them

    sorry on top of it for now, looking up the value for
    olFormatHTML

  4. #19
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    One or two objects should suffice if memory serves me correctly. I need to get to bed. I think Gilligan is finally going to get off of that Island and I don't want to miss it.

    Post up some code using the link I provided and we can proof read what you got.

  5. #20
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    One or two objects should suffice if memory serves me correctly. I need to get to bed. I think Gilligan is finally going to get off of that Island and I don't want to miss it.

    Post up some code using the link I provided and we can proof read what you got.
    Gilligan is right here with me helping, that's why everything is going so wel..... oh...

    will post

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Advantage with early binding is intellisense popup tips. So you can use it until you're sure the code works properly then change it to late binding before distribution.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    code

    Here is the code so far

    I get an error on MailOutLook when it hits the .bodyformat

    says it is missing or deleted....

    I thought creating the object and declaring it 0 would be enough...

    Code:
    If IsNull(Me.txtBeforeDate) Or IsNull(Me.txtAfterDate) Then
    MsgBox "You need to enter in a date range first"
    Else
    
    
    Const cstrPrompt As String = _
            "Are you sure you want all the contacts in this list that have not yet been emailed? Yes/No"
        If MsgBox(cstrPrompt, vbQuestion + vbYesNo) = vbNo Then
            Cancel = True
            ElseIf vbYes Then
    '******************************** Start
    
    
    Dim messagebody As String
    Dim emsubject As String
    Dim emailcont As String
    Dim thecount As String
    Dim mresponse As Integer
    Dim emailofsc As String
    Dim appOutLook As Object
    Dim MailOutLook As Object
    
    
    'check to see if Outlook is installed
       On Error Resume Next
        Set appOutLook = GetObject(, "Outlook.Application")
        On Error GoTo 0
        
        If appOutLook Is Nothing Then
            Set appOutLook = CreateObject("Outlook.Application")
        End If
    
    
    Set MailOutLook = appOutLook.CreateItem(0)
    
    
    
    
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    
    
    'this moves from the first to the last record and counts them to a total.
    rs.MoveFirst
    rs.MoveLast
    thecount = rs.RecordCount
    
    
    
    
    
    
    
    
    If thecount <= 0 Then
    Set rs = Nothing
    Exit Sub
    End If
    
    
    mresponse = MsgBox("Are you sure you want to email " & thecount & " contacts?", vbYesNo, "Continue")
    
    
    
    
    
    
    If mresponse = vbYes Then
    
    
    AlternativeName = IIf(Me.SchoolTypeID = 3, " or the Director, ", IIf(Me.SchoolTypeID = 9, " ", " or the Principal,"))
    
    
    TourOrganiserORPeter = IIf(Me.MergedNameT = Null, "Name" & vbCrLf & "Manager", Me.MergedNameT & vbCrLf & vbCrLf & "Tour Organiser") _
    
    
    
    
    '############################################ this is the email message that gets sent ##################################
    
    
    messagebody = "Dear " & Me.MergedName & AlternativeName _
    & vbCrLf _
    & vbCrLf _
    & "This email is to remind you that " & Me.ShowTitle & " is booked to perform at" _
    & vbCrLf & Me.SchoolName & " on " & Format(Me.BookingDate, "Long Date") & " at" _
    & vbCrLf & Format(Me.ShowTime1st, "Medium Time") & " " & Format(Me.ShowTime2nd, "Medium Time") & " " & Format(Me.ShowTime3rd, "Medium Time") _
    & vbCrLf _
    & vbCrLf & "The Performer/s will arrive at the venue approximately " & Format(Me.SetUpTime, "h") & " hour & " & Format(Me.SetUpTime, "nn") & " minutes before the first performance and will need access to the venue at that time.  The performance is approximately " & Format(Me.ShowLength, "h") & " hour & " & Format(Me.ShowLength, "nn") & " minutes and the performer/s will need approximately " & Format(Me.PackupTime, "h") & " hour & " & Format(Me.PackupTime, "nn") & " minutes after the performance to pack up." _
    & vbCrLf _
    & vbCrLf _
    & "The performer/s will bring with them on the day a tax invoice and appraisal form." _
    & vbCrLf _
    & vbCrLf _
    & "Thank you for including text in your year's activities and we trust you will all enjoy the event." _
    & vbCrLf _
    & vbCrLf _
    & "Sincerely" _
    & vbCrLf _
    & vbCrLf _
    & TourOrganiserORPeter _
    & vbCrLf & "Text" & vbCrLf & "1Text" & vbCrLf & "Text" & vbCrLf & "00 000 000" & vbCrLf & "Email  Text@email.com.au"
    
    
    
    
    '####################################################################################################################################
    
    
    
    
    emsubject = "Reminder of your performance on " & Me.BookingDate
    
    
    rs.MoveFirst
    Do Until rs.EOF
    
    
    'Me.ConfirmationSent4th = -1
        
     If IsNothing(rs![SchoolEmail]) Then
        emailofsc = "noemail"
            Else
        emailofsc = rs![SchoolEmail]
    End If
    If emailofsc = "noemail" Then
    'Me.ConfirmationSent4th = 0
    rs.MoveNext
    Else
    
    
    'open Outlook, attach zip folder or file, send e-mail
    With MailOutLook
    
    
        .BodyFormat = 2
        .To = "email@email.com.au"
        ''.cc = ""
        ''.bcc = ""
        .Subject = msubject & " " & emailofsc
        .HTMLBody = messagebody
        .DeleteAfterSubmit = False 'This would let Outlook send the note without storing it in your sent bin
        .ReadReceiptRequested = True
        .send
    End With
    rs.MoveNext
    End If
    Loop
    MsgBox "all done"
    
    
    Else
    MsgBox "You have cancelled emailing"
    End If
    
    
    
    
    rs.Close
    Set rs = Nothing
    
    
    
    
    
    
    
    
    
    
    End If
    
    
    
    
    
    
    
    
    
    
    '******************************** End
    End If

  8. #23
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Advantage with early binding is intellisense popup tips. So you can use it until you're sure the code works properly then change it to late binding before distribution.
    yes I read about that

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Examples I've seen don't use that line and also don't use HTMLBody, just Body. But seems I've also seen code fail without BodyFormat.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #25
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Examples I've seen don't use that line and also don't use HTMLBody, just Body. But seems I've also seen code fail without BodyFormat.
    Yes, 3 is rich text correct?

    I take out bodyformat - it just moves the error to .To

  11. #26
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I think what you have will work. I tested the following and it worked for me. Remove the reference to Outlook Objects in your reference library thing before you run the code.

    Code:
    Private Sub cmdTest_Click()
    
    Dim appOutLook As Object
    Dim MailOutLook As Object
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(0)
    
    With MailOutLook
        .BodyFormat = 2
        .To = "Email@Domain.com"
        ''.cc = ""
        ''.bcc = ""
        .Subject = "Subject Line"
        .HTMLBody = "This is the body of the Email"
        .DeleteAfterSubmit = False 'This would let Outlook send the note without storing it in your sent bin
        .ReadReceiptRequested = True
        .send
        
    End With
     
    End Sub

  12. #27
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I have tried it even without the reference and it still doesn't work.

    I copied your code to see if that would work - it still gives me the same error

    I retyped everything - same error.

  13. #28
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Click image for larger version. 

Name:	Capture.JPG 
Views:	8 
Size:	18.9 KB 
ID:	14730

    Outlook is​ installed
    '
    and I have also tried this on a different machine - same result

  14. #29
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Can you try on another computer, another system, home computer, work computer?

    The code works for me. Am on home computer now.

    Did you use an actual email address in your code? I send to myself.

    I tested with and without (I was surprised this worked) library reference. With Outlook open or closed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #30
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Something just dawned on me. The only thing late binding is going to do is allow for different versions of Outlook to work. It helps only when you need it to work on machines with Outlook installed.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automated Email using Outlook
    By imran688 in forum Programming
    Replies: 25
    Last Post: 11-12-2012, 03:02 AM
  2. Email and Outlook
    By Douglas Post in forum Programming
    Replies: 1
    Last Post: 02-13-2012, 02:57 PM
  3. email with outlook.application
    By JJCHCK in forum Access
    Replies: 5
    Last Post: 08-25-2011, 06:19 AM
  4. Passing Email Address Into Outlook
    By cg1465 in forum Access
    Replies: 1
    Last Post: 10-01-2010, 07:59 AM
  5. Exporting Outlook email addresses
    By noidea in forum Import/Export Data
    Replies: 0
    Last Post: 08-01-2009, 01:48 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