Go Back   Access World Forums > Microsoft Access Discussion > Forms

Thread Tools Rate Thread Display Modes
Old 08-14-2018, 12:38 PM   #1
Newly Registered User
Join Date: Jul 2018
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
marissela7 is on a distinguished road
Issues sending emails through a form

Hi all! I hope you're well

I'm having three problems here.

Problem 1
I have a form that I use to send emails as a part of it, I added the CC and BCC field and it stopped working and now shows the "Run-time error 94: Invalid use of null" , I don't mind if the CC and BCC fields are blank, it is not always needed to full those fields.

Problem 2:
I did this form a while back and my form has a few tabs, the one with the "mailer tool" shows by default on the "To" field the email that I entered on my first tab with "General information" where the source is another table.
Any thoughts on how to do this again? I can't remember how i did this.

Problem 3:
I need to have a msgbox with the vbYesNo option and then have the email sent if the response is yes and after that a msgbox with a confirmation if email was sent but somehow i cant get that done..

Here is the code:

Dim oapp As New Outlook.Application
Dim oemail As Outlook.MailItem

Set oemail = oapp.CreateItem(olMailItem)
oemail.SentOnBehalfOfName = Me.From
oemail.To = Me.To
oemail.CC = Me.CC
oemail.BCC = Me.BCC
oemail.Subject = Me.Subject
oemail.HTMLBody = Me.Body


msgbox "Email sent!"

Any thoughts?

marissela7 is offline   Reply With Quote
Old 08-14-2018, 12:53 PM   #2
Newly Registered User
June7's Avatar
Join Date: Mar 2014
Posts: 1,950
Thanks: 0
Thanked 462 Times in 458 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Issues sending emails through a form

1. perhaps handle possibility of Null with: Nz(Me.CC, "")

2. if this is a Tab control, controls can reference controls placed on other pages of Tab control

3. If MsgBox("some message", vbYesNo) = vbYes Then
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 08-14-2018, 03:30 PM   #3
Longboard on the internet
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 1,859
Thanks: 17
Thanked 351 Times in 348 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Issues sending emails through a form

Better than the message box, change oemail.Send to oemail.Display so the EMail they are about to send can be edited. That way if they need to add something, say drop an attachment on, they can do so. If they don't want to send it, they can always delete it or save as a draft.

Mark_ is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending emails JohnLee Modules & VBA 4 10-25-2012 03:25 AM
Sending Automatic Emails from a form joshandsony Tables 1 01-09-2010 07:28 PM
Sending Emails using Macro/Form jadeverell Macros 9 06-11-2008 03:46 AM
Sending Emails using Macro/Form jadeverell Macros 1 06-10-2008 03:32 AM
Sending Emails Zifeou Macros 3 08-25-2003 04:45 AM

All times are GMT -8. The time now is 06:26 PM.

Microsoft Access Help
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post

Sponsored Links

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World