Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-14-2018, 12:38 PM   #1
marissela7
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

oemail.Send

msgbox "Email sent!"




Any thoughts?

marissela7 is offline   Reply With Quote
Old 08-14-2018, 12:53 PM   #2
June7
Newly Registered User
 
Join Date: Mar 2014
Posts: 591
Thanks: 0
Thanked 136 Times in 136 Posts
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
__________________
To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.
June7 is offline   Reply With Quote
Old 08-14-2018, 03:30 PM   #3
Mark_
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,491
Thanks: 14
Thanked 272 Times in 270 Posts
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
Reply

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 08:58 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


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