Results 1 to 4 of 4
  1. #1
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45

    Question Help with emailing from access using outlook mailitem

    hello i have a form to send email on my db and work ok, but the problem is now i added a second field to CC receipts because sometimes i need to sent copy of the email to more peoples but using CC

    the problem is that is I leave the CC field empty because I don't need to a an CC the system show RUNTIME ERROR 94 INVALID USE OF NULL

    so how can I skip this error it cc field is empty, and the system send the email?

    here is the code I am using:

    Private Sub Send_Click()
    Dim oApp As Outlook.Application
    Dim oMail As MailItem

    Set oApp = CreateObject("Outlook.application") 'this is the "instance" of Outlook
    Set oMail = oApp.CreateItem(olMailItem) 'this is the actual "email"



    'Here the body, subject, mail etc is hardcoded.


    'You could get this info straight from the form and/or tables to have dynamic code
    oMail.Body = Me.txtbody
    oMail.Subject = Me.Txtsubject
    oMail.To = Me.txtemail
    oMail.Subject = Me.Txtsubject
    oMail.CC = Me.txtcc

    oMail.Send 'this sends the mail
    Set oMail = Nothing
    Set oApp = Nothing

    End Sub




    thanks in advance

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Code:
    If Len(Me.txtcc & vbNullString) > 0 Then
      oMail.CC = Me.txtcc
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    You are the besttt.. thankssss

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 04-08-2014, 11:59 AM
  2. Outlook Emailing
    By moita in forum Import/Export Data
    Replies: 9
    Last Post: 03-25-2014, 10:14 AM
  3. PDF Creation and Emailing via Outlook
    By Tomlon in forum Programming
    Replies: 1
    Last Post: 07-16-2012, 11:42 AM
  4. Replies: 3
    Last Post: 12-05-2011, 02:19 PM
  5. EMailing Through Access
    By mamta in forum Programming
    Replies: 5
    Last Post: 02-15-2010, 01:07 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