UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Email, Access 2016    
 
   
mike60smart
post Apr 1 2020, 06:46 AM
Post#1


UtterAccess VIP
Posts: 13,906
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I am trying to use the following Code to send an Email to a number of CC.

It only send to strCC1 but not to strCC2

How can I amend the code to achieve this?

Also when I click the Command Button it automatically sends the Email.

How can I also amend the Code to just pop up the Email?

Any help appreciated.

CODE
Private Sub cmdEMail_Click()

10        On Error GoTo cmdEMail_Click_Error
      Dim OutApp As Object
      Dim OutMail As Object
      Dim strToSQL As String
      Dim strCC1 As String
      Dim strCC2 As String
      Dim strSubject As String
      Dim strMessage As String

20    strToSQL = Me.txtTo
30    strSubject = "Errors"
40    strCC1 = Me.txtCC1
50    strCC2 = Me.txtCC2
60    strMessage = "The Error Date was " & [ED] & " and the Error Type " & _
               [ET] & " with the concern being " & [QC]

70    Set OutApp = CreateObject("Outlook.Application")
80    Set OutMail = OutApp.CreateItem(0)

90    On Error Resume Next
100   With OutMail
110     .To = strToSQL
120     .CC = strCC1
130     .CC = strCC2
        
140     .Subject = strSubject
        
150     .Body = strMessage
        
        .Send
160   End With

          
170       On Error GoTo 0
180       Exit Sub

cmdEMail_Click_Error:

190       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdEMail_Click, line " & Erl & "."

End Sub

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
JeffK
post Apr 1 2020, 07:57 AM
Post#2


UtterAccess VIP
Posts: 1,613
Joined: 19-December 02
From: Lansing, MI


To include multiple CC, set the property only once, with addresses separated by a semicolon:

.CC = strCC1 & ";" & strCC2

To display the email instead of sending it, replace .Send with .Display. In the example code I found in my library I'm supplying an argument to Display for whether it should be modal or not. I'm not sure if that argument is required.
Go to the top of the page
 
pere_de_chipstic...
post Apr 1 2020, 08:13 AM
Post#3


UtterAccess Editor
Posts: 10,624
Joined: 8-November 07
From: South coast, England


PMFJI

Just curious, with the concern about data protection should you send to everyone using a cc list? wouldn't the bcc list be better?

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Apr 1 2020, 08:34 AM
Post#4


UtterAccess VIP
Posts: 13,906
Joined: 6-June 05
From: Dunbar,Scotland


Hi Bernie

The EMails are all within the same organisation.


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
DanielPineault
post Apr 1 2020, 08:45 AM
Post#5


UtterAccess VIP
Posts: 7,336
Joined: 30-June 11



You'd be much better off using an E-mail function and simply calling it when you need such functionalities, refer to https://www.devhut.net/2010/09/03/vba-send-...ook-automation/ this way all the coding is already done for you. grin.gif

--------------------
Daniel Pineault (2010-2019 Microsoft MVP, UA VIP, EE Distinguished Expert 2018)
Professional Help: https://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: https://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
pere_de_chipstic...
post Apr 1 2020, 09:09 AM
Post#6


UtterAccess Editor
Posts: 10,624
Joined: 8-November 07
From: South coast, England


No worries then thumbup.gif

This was a problem I encountered when sending group e-mails out to members of our choir, all within the choir organization, but private e-mail addresses.

I also use Daniel's approach, and use an e-mail UDF.

Cheers

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Apr 1 2020, 11:18 AM
Post#7


UtterAccess VIP
Posts: 13,906
Joined: 6-June 05
From: Dunbar,Scotland


Hi Jeff

That works just great

Many thanks
cheers.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
JeffK
post Apr 1 2020, 12:31 PM
Post#8


UtterAccess VIP
Posts: 1,613
Joined: 19-December 02
From: Lansing, MI


Great, gl!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    24th May 2020 - 07:52 PM