I use this public function: - Public Function SendAnEmail(olSendTo As String, _
-
olSubject As String, _
-
olEMailBody As String, _
-
olDisplay As Boolean, _
-
Optional olCCLine As String, _
-
Optional olBCCLine As String, _
-
Optional olOnBehalfOf As String, _
-
Optional olAtchs As String, _
-
Optional SendAsHTML As Boolean) As Boolean
-
On Error GoTo EH
-
Dim olApp As Outlook.Application
-
Dim olMail As Outlook.MailItem
-
Dim strArray() As String
-
Dim intAtch As Integer
-
-
Set olApp = CreateObject("Outlook.Application")
-
Set olMail = olApp.CreateItem(olMailItem)
-
With olMail
-
.To = olSendTo
-
.subject = olSubject
-
-
If SendAsHTML Then
-
.BodyFormat = olFormatHTML
-
.HTMLBody = olEMailBody
-
Else
-
.body = olEMailBody
-
End If
-
-
.CC = olCCLine
-
.BCC = olBCCLine
-
.SentOnBehalfOfName = olOnBehalfOf
-
strArray = Split(olAtchs, "%Atch")
-
-
For intAtch = 0 To UBound(strArray)
-
If FileExists(strArray(intAtch)) Then _
-
.Attachments.Add strArray(intAtch)
-
Next intAtch
-
-
If olDisplay Then
-
.Display
-
Else
-
.Send
-
End If
-
-
End With
-
Set olMail = Nothing
-
Set olApp = Nothing
-
-
SendAnEmail = True
-
-
Exit Function
-
EH:
-
MsgBox "There was an error generating the E-Mail!" & vbCrLf & vbCrLf & _
-
"Error: " & Err.Number & vbCrLf & _
-
"Description: " & Err.Description & vbCrLf & vbCrLf & _
-
"Please contact your Database Administrator.", vbCritical, "WARNING!"
-
SendAnEmail = False
-
Exit Function
-
End Function
Which is called out in this sub routine: - Private Sub btnGroupEmail_Click()
-
-
On Error GoTo EH
-
-
Dim strSendTo As String
-
Dim strSubject As String
-
Dim strEMailBody As String
-
Dim strCCLine As String
-
Dim strBCCLine As String
-
Dim strOnBehalfOf As String
-
Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
Dim strEMail As String
-
-
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "qryEmail", acViewNormal
-
DoCmd.SetWarnings True
-
-
Set MyDB = CurrentDb
-
-
Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", _
-
dbOpenSnapshot, dbOpenForwardOnly)
-
-
With rstEMail
-
If Not (.BOF And .EOF) Then
-
Call .MoveFirst
-
Do While Not .EOF
-
'Build the Recipients String
-
strSendTo = _
-
strSendTo & _
-
IIf(strSendTo = "", _
-
"", _
-
";") & !Email
-
Call .MoveNext
-
Loop
-
End If
-
Call .Close
-
End With
-
-
Call MyDB.Close
-
Set rstEMail = Nothing
-
Set MyDB = Nothing
-
-
'Generate and Display the E-Mail
-
-
Call SendAnEmail(olSendTo:=strSendTo, _
-
olSubject:=strSubject, _
-
olEMailBody:=strEMailBody, _
-
olDisplay:=True, _
-
SendAsHTML:=True)
-
-
Exit Sub
-
EH:
-
MsgBox "There was an error sending mail!" & vbCrLf & vbCrLf & _
-
"Error: " & Err.Number & vbCrLf & _
-
"Description: " & Err.Description & vbCrLf & vbCrLf & _
-
"Please contact your Database Administrator.", vbCritical, "WARNING!"
-
Exit Sub
-
-
End Sub
My question is "How Would I send this as BCC: only"?
Tried changing the strSendto string to strBCCLine string in all instances and all that happens is a blank email.
- Call SendAnEmail(olSendTo:="", _
-
olSubject:=strSubject, _
-
olEMailBody:=strEMailBody, _
-
olBCCLine:=strSendTo, _
-
olDisplay:=True, _
-
SendAsHTML:=True)
You should be better able to troubleshoot these by now, DJ....
5 2168
DJ,
Easy: - Call SendAnEmail(olBCCLine:=strSendTo, _
-
olSubject:=strSubject, _
-
olEMailBody:=strEMailBody, _
-
olDisplay:=True, _
-
SendAsHTML:=True)
You are confusing your variables with your arguments.
Hope this hepps!
So I changed that, but now it doesn't compile. It tells me
"Argument not optional" in this section: - Call SendAnEmail(olBCCLine:=strSendTo, _
-
olSubject:=strSubject, _
-
olEMailBody:=strEMailBody, _
-
olDisplay:=True, _
-
SendAsHTML:=True)
- Call SendAnEmail(olSendTo:="", _
-
olSubject:=strSubject, _
-
olEMailBody:=strEMailBody, _
-
olBCCLine:=strSendTo, _
-
olDisplay:=True, _
-
SendAsHTML:=True)
You should be better able to troubleshoot these by now, DJ....
Thanks Twinny,
Still finding some of this stuff confusing.
No worries, DJ!
Keep pluggin' away. Soon things will start to become natural. It takes many years to become comfortable with this stuff. You'll get there! Just stay encouraged and keep asking questions!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: NotGiven |
last post by:
|
by: Samia |
last post by:
I have an application running on a single workstation (win 2000) with
Outlook installed and a profile create using and exchange server with
authentification through the DNS. This user profile is...
|
by: mhawkins19 |
last post by:
I have a form built and on the onclick event I validate all of the
fields and then if the form is ok, on the submit event I run a
javascript function to set a cookie and download a file from the...
|
by: Jay McGrath |
last post by:
Help - trying to send a simple text email with with as little user
intervention.
I am trying to create a button in my Access application that will
automatically send a simple text email. It...
|
by: Bob Jones |
last post by:
We have developed a commercial ASP.net application
(personal nutrition management and tracking); we want to
send smtp email from within it.
For our development box, we use WinXP Pro, IIS 5.5,...
|
by: =?Utf-8?B?SHVnaA==?= |
last post by:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused...
|
by: =?Utf-8?B?cGF0cmlja2RyZA==?= |
last post by:
Hi guys!
I'm looking for a way to send an email from the server to the user
(like a newsletter).
How can I do this?
Does anyone know of a sample code link or something like that?
Do I...
|
by: =?Utf-8?B?Q2hlZg==?= |
last post by:
I can use outlook2003 to send email,but I cann't use this code below to send
email.
Please help me to test this code and instruct me how to solve this problem
in detail.
software...
|
by: shailendra deshpande |
last post by:
right now i have only pain html page.and i want to send email through
it using javascript
plz. anybody tell me how to send email from plain html page using
javascript.
thanks in advance
...
|
by: Warren Tang |
last post by:
Hi
I am using the mail function to send a mail like this:
$b = mail("my_real_email_address@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");
But it failed. Could you...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |