Results 1 to 4 of 4
  1. #1
    arrowmakersuk is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    2

    Email coding

    Hi Im a newbie to this VB coding and need some help with some code I am usinf to try and take data from a form and email it to a workmate.I have left the fields from the form in begin with OTR , but I cant get the form field onto the email and now Ive started getting a run time error 287 application defined or object defined error and Im now lost in a forest of trees
    Any help would be appreciated

    Private Sub send_Click()
    Dim strEmail, strBody As String
    Dim objOutlook As Outlook.Application
    Dim objEmail As Outlook.MailItem



    Set objOutlook = CreateObject("Outlook.application")
    Set objEmail = objOutlook.CreateItem(olMailItem)
    '************************************************* *************

    strEmail = "123456@btinternet.com"

    strBody = strBody & "We have received a Request and are processing to issue promptly the following OTR Request" & _
    " below to ensure our accuracy." & Chr(13) & Chr(13) & Chr(13)
    strBody = strBody & "Client: " & OTRPartnership & "Site: " & OTRSite & Chr(13)
    strBody = strBody & "Issue By: " & OTRStaff & Chr(13)
    strBody = strBody & "Quantity: " & OTRQuant & Chr(13)
    strBody = strBody & "Sequence: " & OTRSequence & Chr(13)
    strBody = strBody & "OTR Purchase Number: " & OTRPONumber & Chr(13)
    strBody = strBody & "Delivery Date: " & OTRDeliveryDate & Chr(13)
    strBody = strBody & "Sincerely" & Chr(13) & Chr(13)
    strBody = strBody & "" & Chr(13) & Chr(13)

    With objEmail
    .To = strEmail
    .Subject = "New OTR Request"
    .Body = strBody
    .send
    End With

    Set objEmail = Nothing

    objOutlook.Quit
    Exit Sub

    End Sub

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,055

  3. #3
    arrowmakersuk is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    2
    Grt that thanks , but my main problem is getting the form data into the email any ideas

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,055
    In this code
    strBody = strBody & "We have received a Request and are processing to issue promptly the following OTR Request" & _
    " below to ensure our accuracy." & Chr(13) & Chr(13) & Chr(13)
    strBody = strBody & "Client: " & OTRPartnership & "Site: " & OTRSite & Chr(13)
    strBody = strBody & "Issue By: " & OTRStaff & Chr(13)
    strBody = strBody & "Quantity: " & OTRQuant & Chr(13)
    strBody = strBody & "Sequence: " & OTRSequence & Chr(13)
    strBody = strBody & "OTR Purchase Number: " & OTRPONumber & Chr(13)
    strBody = strBody & "Delivery Date: " & OTRDeliveryDate & Chr(13)
    strBody = strBody & "Sincerely" & Chr(13) & Chr(13)
    strBody = strBody & "" & Chr(13) & Chr(13)

    Put Me.OTRPartnership for each of you reference to OTR things. Me. is a reference to the current form

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

Similar Threads

  1. Complex Coding --> Please Help
    By JFo in forum Programming
    Replies: 231
    Last Post: 11-03-2011, 01:20 AM
  2. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  3. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM
  4. Button Coding
    By yamie in forum Programming
    Replies: 3
    Last Post: 02-22-2010, 10:45 AM
  5. Bar-Coding
    By texasprincess7 in forum Access
    Replies: 1
    Last Post: 02-12-2009, 10:29 AM

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