How do I automate Outlook to send an e-mail using VBA?

G

Guest

I have a VBA code to send an object through e-mail automatically, but when
the code runs I always get a warning message stating " A Program is trying to
automatically send e-mail on your behalf. Do you want to allow this?" and the
coding pauses to wait for an answer from you. Now how do I go about removing
this message or bypassing it to automatically send the e-mail without this
popping up?
 
S

strive4peace

for constructing Outlook messages from Access, here is some
code posted by Ricky Hicks ...

'~~~~~~~~~~~~~~~
Function MailParameters()

Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
'.Importance = olImportanceHigh
.To = Me.eMailAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
' .Subject = "YOUR SUBJECT GOES HERE"
' .Body = "YOUR_E-MAIL_MESSAGE_GOES_HERE"
'.Attachments.Add _
"YOUR FILE PATH AND NAME"

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

End Function
'~~~~~~~~~~~~~~~

If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Is there anyway around this without using a third party? I've tried sendkeys,
saving to the outbox and others..... no cookie yet.






:
 
G

Guest

Function MailParameters()
Dim outApp As Outlook.Application, outMsg As MailItem
...
The code above requires me to first set a Type … End Type, which I assume
looks something like this:

Type EmployeeRecord ' Create user-defined type.
ID As Integer ' Define elements of data type.
Name As String * 20
Address As String * 30
Phone As Long
HireDate As Date
End Type

But I don’t know which parameters from your original code to put in here.
Any help is appreciated.

I ultimately would like to be able to build a message from Access, and
insert a jpg picture that shows up in email, but I would settle for it being
attached.
+ + + +++ + + + +++ + + + +++ + + + +++ + + + +++ + + + +++
 
S

strive4peace

Hi Michael,

in order for this code to compile, you need to set a
reference to the Microsoft Outlook Library -- Tools,
References from a module window

If you have a table with this structure:

EmpID, autonumber (stored as long integer)
Firstname, text, 20 or 30
AllowZeroLength --> yes
Lastname, text, 20 or 30
eAddress, text, 50
Address, text, 30
AllowZeroLength --> yes
Phone, text, 14,
InputMask --> !(999) 000-0000;0;_
AllowZeroLength --> yes
HireDate, date
Filenam, text, 255
--> change fieldname, Filenam, to specify what
kid of file it is


and a form with these fields

then, the code would go behind the form...

'~~~~~~~~~~~~~~
Dim outApp As Outlook.Application, outMsg As MailItem

Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)

With outMsg
'.Importance = olImportanceHigh
.To me.eAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
.Subject = "The subject line"
.Body = "Your file is attached
.Attachments.Add me.Filenam

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

'~~~~~~~~~~~~~~~

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
S

strive4peace

this should have said

..To = me.eAddress

if you want to personalize the body of the message, you
could do something like this ...

..Body = "Hi " & trim(me.firstname & " " & me.lastname) _
& ", Your file is attached -- from Michael"


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

You said:
If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments, but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John
 
S

strive4peace

Hi John,

what is it that you are trying to send... an Access report perhaps? If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'================================================================= Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
G

Guest

Hello,

I need to be able to attach files (not msaccess internal objects).
I found the "CDO.Message" way. I'm about to give it a try.

Thanks for your answer.
John

strive4peace said:
Hi John,

what is it that you are trying to send... an Access report perhaps? If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'================================================================= Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments, but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John
 
S

strive4peace

Hi John,

that is great, are there a couple good links you can share?

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hello,

I need to be able to attach files (not msaccess internal objects).
I found the "CDO.Message" way. I'm about to give it a try.

Thanks for your answer.
John

strive4peace said:
Hi John,

what is it that you are trying to send... an Access report perhaps? If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'================================================================= Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


You wrote:
If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments, but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John


:

for constructing Outlook messages from Access, here is some
code posted by Ricky Hicks ...

'~~~~~~~~~~~~~~~
Function MailParameters()

Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
'.Importance = olImportanceHigh
.To = Me.eMailAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
' .Subject = "YOUR SUBJECT GOES HERE"
' .Body = "YOUR_E-MAIL_MESSAGE_GOES_HERE"
'.Attachments.Add _
"YOUR FILE PATH AND NAME"

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

End Function
'~~~~~~~~~~~~~~~

If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

scariharry wrote:
Is there anyway around this without using a third party? I've tried sendkeys,
saving to the outbox and others..... no cookie yet.






:


You can also use Redemption
http://www.dimastr.com/redemption/


-----Original Message-----
Download this program it will click yes automatically

http://www.snapfiles.com/get/clickyes.html
 
G

Guest

Hello,

I was already thinking to share the code, but it wasn't complete.
Here's a working copy of the "CDO.Message way" I'm using to send e-mail
messages with file attachments (sorry, I don't remember the source links I
explored):

' --------------------------------------------
Dim iMsg As Object
Dim iConf As Object
Dim iBP
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .Configuration = iConf
.to = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.BCC = "(e-mail address removed)"
.From = "(e-mail address removed)"
.Subject = "something"
.TextBody = "something"
iBP = AddAttachment("full path to a file name")
.send
End With

Set iBP = Nothing
Set iMsg = Nothing
Set iConf = Nothing
' --------------------------------------------

If you'd like to attach more than one file, you can use the character "," as
delimiter to the file names.

Regards,
John

strive4peace said:
Hi John,

that is great, are there a couple good links you can share?

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hello,

I need to be able to attach files (not msaccess internal objects).
I found the "CDO.Message" way. I'm about to give it a try.

Thanks for your answer.
John

strive4peace said:
Hi John,

what is it that you are trying to send... an Access report perhaps? If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'================================================================= Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



JohnA wrote:
You wrote:
If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments, but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John


:

for constructing Outlook messages from Access, here is some
code posted by Ricky Hicks ...

'~~~~~~~~~~~~~~~
Function MailParameters()

Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
'.Importance = olImportanceHigh
.To = Me.eMailAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
' .Subject = "YOUR SUBJECT GOES HERE"
' .Body = "YOUR_E-MAIL_MESSAGE_GOES_HERE"
'.Attachments.Add _
"YOUR FILE PATH AND NAME"

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

End Function
'~~~~~~~~~~~~~~~

If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

scariharry wrote:
Is there anyway around this without using a third party? I've tried sendkeys,
saving to the outbox and others..... no cookie yet.






:


You can also use Redemption
http://www.dimastr.com/redemption/


-----Original Message-----
Download this program it will click yes automatically

http://www.snapfiles.com/get/clickyes.html
 
D

Douglas J. Steele

What's AddAttachment, John?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JohnA said:
Hello,

I was already thinking to share the code, but it wasn't complete.
Here's a working copy of the "CDO.Message way" I'm using to send e-mail
messages with file attachments (sorry, I don't remember the source links I
explored):

' --------------------------------------------
Dim iMsg As Object
Dim iConf As Object
Dim iBP
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .Configuration = iConf
.to = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.BCC = "(e-mail address removed)"
.From = "(e-mail address removed)"
.Subject = "something"
.TextBody = "something"
iBP = AddAttachment("full path to a file name")
.send
End With

Set iBP = Nothing
Set iMsg = Nothing
Set iConf = Nothing
' --------------------------------------------

If you'd like to attach more than one file, you can use the character ","
as
delimiter to the file names.

Regards,
John

strive4peace said:
Hi John,

that is great, are there a couple good links you can share?

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hello,

I need to be able to attach files (not msaccess internal objects).
I found the "CDO.Message" way. I'm about to give it a try.

Thanks for your answer.
John

:

Hi John,

what is it that you are trying to send... an Access report perhaps?
If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'=================================================================
Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress
_
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



JohnA wrote:
You wrote:
If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with
that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments,
but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John


:

for constructing Outlook messages from Access, here is some
code posted by Ricky Hicks ...

'~~~~~~~~~~~~~~~
Function MailParameters()

Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
'.Importance = olImportanceHigh
.To = Me.eMailAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
' .Subject = "YOUR SUBJECT GOES HERE"
' .Body = "YOUR_E-MAIL_MESSAGE_GOES_HERE"
'.Attachments.Add _
"YOUR FILE PATH AND NAME"

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

End Function
'~~~~~~~~~~~~~~~

If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

scariharry wrote:
Is there anyway around this without using a third party? I've tried
sendkeys,
saving to the outbox and others..... no cookie yet.






:


You can also use Redemption
http://www.dimastr.com/redemption/


-----Original Message-----
Download this program it will click yes automatically

http://www.snapfiles.com/get/clickyes.html
 
S

strive4peace

Thanks, John

what libraries need to be referenced?

.... and ditto on Doug's question. Do you have code for AddAttachment
that you can post? What does it return?

what is iBP ?

you don't dimension it as an object, yet you set it to nothing when you
release variables.

How does the attachment(s) actually get attached?

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hello,

I was already thinking to share the code, but it wasn't complete.
Here's a working copy of the "CDO.Message way" I'm using to send e-mail
messages with file attachments (sorry, I don't remember the source links I
explored):

' --------------------------------------------
Dim iMsg As Object
Dim iConf As Object
Dim iBP
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

With iMsg
Set .Configuration = iConf
.to = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.BCC = "(e-mail address removed)"
.From = "(e-mail address removed)"
.Subject = "something"
.TextBody = "something"
iBP = AddAttachment("full path to a file name")
.send
End With

Set iBP = Nothing
Set iMsg = Nothing
Set iConf = Nothing
' --------------------------------------------

If you'd like to attach more than one file, you can use the character "," as
delimiter to the file names.

Regards,
John

strive4peace said:
Hi John,

that is great, are there a couple good links you can share?

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hello,

I need to be able to attach files (not msaccess internal objects).
I found the "CDO.Message" way. I'm about to give it a try.

Thanks for your answer.
John

:

Hi John,

what is it that you are trying to send... an Access report perhaps? If
so, this code uses the dafault email application...

'~~~~~~~~~~~~~~~~~~~~~~~
'================================================================= Email
'SendObject
'[objecttype]
'[, objectname]
'[, outputformat]
'[, to]
'[, cc]
'[, bcc]
'[, subject]
'[, messagetext]
'[, editmessage]
'[, templatefile]

'------------------------------------ EMailReport
Sub EMailReport( _
pReportName As String _
, pEmailAddress As String _
, pFriendlyName As String _
, pBooEditMessage As Boolean _
, pWhoFrom As String _
, Optional ByVal pFormat As String)

'Email a report to someone and construct the subject and message
'SNAPSHOT Format

'example useage: on the command button code to process a report
' EMailReport "rptSonglist", "(e-mail address removed)", _
"A List of the Original Songs from an upcoming Star", _
false, "Susan Manager"

'PARAMETERS
'pReportName --> "rptSonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> "List of the Original Songs from upcoming Star"
'pBooEditMessage --> true to edit message before mail is sent
' --> false send automatically
'pWhoFrom --> "Susan Manager"

On Error GoTo Proc_Err
On Error Resume Next

Dim mFormat As String
If Len(Nz(pFormat)) = 0 Then
pFormat = "SNP"
End If

If pFormat <> "SNP" Then
mFormat = "Rich Text Format (*.rtf)"
Else
mFormat = "Snapshot Format (*.snp)"
End If

'----------------------- Email it
DoCmd.SendObject acSendReport, pReportName, mFormat, pEmailAddress _
, , , pFriendlyName & Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " & pWhoFrom, pBooEditMessage

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , "ERROR " & Err.Number & " EMailReport"
'press F8 to find problem and fix
' -- comment out next line when code is done
Stop: Resume

Resume Proc_Exit

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



JohnA wrote:
You wrote:
If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

Could you please give me this "other method"?
I'm trying to send a mail through MSAccess, I have no problem with that, but
I can't send any attachments, because I'm using the "SendObject" way.
The "CreateObject("Outlook.Application")" way can send attachments, but I'm
using Outlook Express. I've tried
"CreateObject("OutlookExpress.Application")", but it didn't work.
Any ideas?

Many thanks,
John


:

for constructing Outlook messages from Access, here is some
code posted by Ricky Hicks ...

'~~~~~~~~~~~~~~~
Function MailParameters()

Dim outApp As Outlook.Application, outMsg As MailItem
Set outApp = CreateObject("Outlook.Application")
Set outMsg = outApp.CreateItem(olMailItem)
With outMsg
'.Importance = olImportanceHigh
.To = Me.eMailAddress
'.CC = "CC EMAIL ADDRESS GOES HERE"
'.BCC = "BCC EMAIL ADDRESS GOES HERE"
' .Subject = "YOUR SUBJECT GOES HERE"
' .Body = "YOUR_E-MAIL_MESSAGE_GOES_HERE"
'.Attachments.Add _
"YOUR FILE PATH AND NAME"

' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With

Set outApp = Nothing
Set outMsg = Nothing

End Function
'~~~~~~~~~~~~~~~

If you are using Outlook Express, there is another method


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

scariharry wrote:
Is there anyway around this without using a third party? I've tried sendkeys,
saving to the outbox and others..... no cookie yet.






:


You can also use Redemption
http://www.dimastr.com/redemption/


-----Original Message-----
Download this program it will click yes automatically

http://www.snapfiles.com/get/clickyes.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top