Issues sending emails through a form (1 Viewer)

marissela7

New member
Local time
Yesterday, 23:55
Joined
Jul 31, 2018
Messages
3
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?
 

June7

AWF VIP
Local time
Yesterday, 20:55
Joined
Mar 9, 2014
Messages
5,465
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
 

Mark_

Longboard on the internet
Local time
Yesterday, 21:55
Joined
Sep 12, 2017
Messages
2,111
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.
 

Users who are viewing this thread

Top Bottom