Results 1 to 5 of 5
  1. #1
    msixpackabs is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    11

    Question Automatically copy / paste To, CC, Subject. Body message to outlook

    Click image for larger version. 

Name:	Untitled.png 
Views:	9 
Size:	137.8 KB 
ID:	24979
    This is the result of a user friendly menu in my app.


    Is there any way I could have this exported to Outlook in the corresponding fields by just clicking on a button?
    I want them to be exported as text but nod pdf or other "images".
    Ty

    eg. email1; email2 to To:
    Subject to subject and so on

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Code:
    sub btnSend_click()
      email1 txtTO, txtSubj , txtBbody
    end sub
    
    '-------
    'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!!   checkmark MICROSOFT OUTLOOK OBJECT LIBRARY in the vbE menu, Tools, References
    '-------
    Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody) As Boolean
    Dim oApp As Outlook.Application
    Dim oMail As Outlook.MailItem
    On Error GoTo ErrMail
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(olMailItem)
    With oMail
        .To = pvTo
        .Subject = pvSubj
        .Body = pvBody
        '.Attachments.Add activeworkbook.FullName, olByValue, 1
        
        .Send
    End With
    EmailO = True
    Set oMail = Nothing
    Set oApp = Nothing
    Exit Function
    ErrMail:
    MsgBox Err.Description, vbCritical, Err
    Resume Next
    End Function

  3. #3
    msixpackabs is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    11
    it won't work
    I changed the names into txtTo, txtSubj...etc
    checkmarked the references
    if to files is null says invalid use of null
    when all info complete...it does nothing

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    did you add OUTLOOK to the references?
    did you use the correct text box names on your form?
    did you stop the code (f9) inside the email to see if all the data is passing thru to the email code?

  5. #5
    msixpackabs is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    11
    TY very much! I really appreciate it!
    Unfortunately for a dumb ass like me, I sent lots of messages without knowing
    I assumed outlook will open but it didn't
    Wrote the proper code to prevent user from seeing the "module" errors and it work like a charm!
    Once again, thank you!

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

Similar Threads

  1. Replies: 6
    Last Post: 06-22-2016, 03:43 AM
  2. Replies: 4
    Last Post: 08-04-2015, 01:33 PM
  3. Replies: 2
    Last Post: 01-23-2014, 12:40 PM
  4. Field Name into Subject/Body of an email?
    By Stanggirlie in forum Programming
    Replies: 0
    Last Post: 01-05-2009, 11:51 AM
  5. Email field name into subject/body?
    By Stanggirlie in forum Access
    Replies: 0
    Last Post: 01-02-2009, 11:07 AM

Tags for this Thread

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