S
strive4peace
Hello Gene,
As a user of Outlook Express, I have had a hard time
figuring out how to send attachments without references to a
specific package in code (such as to Outlook, not Outlook
Express). I have copied code from Ricky Hicks on how to
construct messages using Outlook (which seems to work
great), but have found nothing specifically for Outlook
Express ...not that it isn't out there, just that I haven't
found it...
this said ...
Here is some logic for you (but I am sorry, I cannot tell
you, at the present moment, how to implement everything in
code).
1. output to Excel
2. link to Excel
3. make query based on linked table
4. use SendObject, which will use your default eMail program
Here is a start:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'3. make query based on linked table
'------------------------------------ MakeQuery
Sub MakeQuery( _
ByVal pSql As String, _
ByVal qName As String)
'modified 10-22-05
On Error GoTo MakeQuery_error
Dim mStr As String, mBooMake As Boolean
'if query already exists, update the SQL
'if not, create the query
mBooMake = True
DoCmd.Echo False
DoCmd.SetWarnings False
On Error Resume Next
Err.Number = 0
mStr = CurrentDb.QueryDefs(qName).Name
If Err.Number = 0 Then mBooMake = False
On Error GoTo MakeQuery_error
DoCmd.Echo True
DoCmd.SetWarnings True
If mBooMake Then
CurrentDb.CreateQueryDef qName, pSql
Else
CurrentDb.QueryDefs(qName).sql = pSql
End If
MakeQuery_exit:
CurrentDb.QueryDefs.Refresh
DoEvents
Exit Sub
MakeQuery_error:
MsgBox Err.Description, , "ERROR " & Err.Number & "
MakeQuery"
DoCmd.Echo True
DoCmd.SetWarnings True
Stop
'Press F8 to step through code and find problem
'comment out when program is debugged
Resume
Resume MakeQuery_exit
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4. use SendObject, which will use your default eMail program
'========================================= Email
'------------------------------------ EMailReport
'send a message through the DEFAULT Email program
'
Sub eMailObject ( _
pSendType as Long, _
pObjectName As String, _
pEmailAddress As String, pFriendlyName As String, _
pBooEditMessage As Boolean, _
pWhoFrom As String)
'Email attachment to someone
'and construct the subject and message
'example useage:
' on the command button code to process a report -->
' EMailReport _
"qrySonglist", _
"(e-mail address removed)", _
"Original Songs from an upcoming Star", _
false, _
"Susan Manager"
'PARAMETERS
'pSendType -->
' acSendReport = 3
' filter property need be saved
' acSendForm = 2
' the active form filter will be respected
' acSendQuery = 1
' ... etc
'pObjectName --> "qrySonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> Original Songs from an upcoming Star"
'pBooEditMessage --> true if you want to edit message
' before mail is sent
' --> false to send automatically
'pWhoFrom --> "Susan Doe"
On Error GoTo EMailReport_error
'you can substitute acFormatSNP
' --> acFormatHTML
' --> acFormatRTF
' --> acFormatXLS
' --> acFormatTXT
' etc
on error goto Err_proc
DoCmd.SendObject _
pSendType, _
pObjectName, _
acFormatSNP, _
pEmailAddress _
, , , pFriendlyName _
& Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " _
& pWhoFrom, _
pBooEditMessage
Exit_proc:
Exit Sub
Err_proc:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " eMailObject"
'press F8 to find problem and fix
'comment or remove next line when code is done
Stop : Resume
Resume Exit_proc
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I must apologize, for some of this is "air-code" ... I
renamed parameters and added comments to code that I had
already written and tested ... if you see errors, I would
appreciate knowing what they are...
Warm Regards,
Crystal
Microsoft Access MVP 2006
remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day
As a user of Outlook Express, I have had a hard time
figuring out how to send attachments without references to a
specific package in code (such as to Outlook, not Outlook
Express). I have copied code from Ricky Hicks on how to
construct messages using Outlook (which seems to work
great), but have found nothing specifically for Outlook
Express ...not that it isn't out there, just that I haven't
found it...
this said ...
Here is some logic for you (but I am sorry, I cannot tell
you, at the present moment, how to implement everything in
code).
1. output to Excel
2. link to Excel
3. make query based on linked table
4. use SendObject, which will use your default eMail program
Here is a start:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'3. make query based on linked table
'------------------------------------ MakeQuery
Sub MakeQuery( _
ByVal pSql As String, _
ByVal qName As String)
'modified 10-22-05
On Error GoTo MakeQuery_error
Dim mStr As String, mBooMake As Boolean
'if query already exists, update the SQL
'if not, create the query
mBooMake = True
DoCmd.Echo False
DoCmd.SetWarnings False
On Error Resume Next
Err.Number = 0
mStr = CurrentDb.QueryDefs(qName).Name
If Err.Number = 0 Then mBooMake = False
On Error GoTo MakeQuery_error
DoCmd.Echo True
DoCmd.SetWarnings True
If mBooMake Then
CurrentDb.CreateQueryDef qName, pSql
Else
CurrentDb.QueryDefs(qName).sql = pSql
End If
MakeQuery_exit:
CurrentDb.QueryDefs.Refresh
DoEvents
Exit Sub
MakeQuery_error:
MsgBox Err.Description, , "ERROR " & Err.Number & "
MakeQuery"
DoCmd.Echo True
DoCmd.SetWarnings True
Stop
'Press F8 to step through code and find problem
'comment out when program is debugged
Resume
Resume MakeQuery_exit
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4. use SendObject, which will use your default eMail program
'------------------------------------ EMailReport
'send a message through the DEFAULT Email program
'
Sub eMailObject ( _
pSendType as Long, _
pObjectName As String, _
pEmailAddress As String, pFriendlyName As String, _
pBooEditMessage As Boolean, _
pWhoFrom As String)
'Email attachment to someone
'and construct the subject and message
'example useage:
' on the command button code to process a report -->
' EMailReport _
"qrySonglist", _
"(e-mail address removed)", _
"Original Songs from an upcoming Star", _
false, _
"Susan Manager"
'PARAMETERS
'pSendType -->
' acSendReport = 3
' filter property need be saved
' acSendForm = 2
' the active form filter will be respected
' acSendQuery = 1
' ... etc
'pObjectName --> "qrySonglist"
'pEmailAddress --> "(e-mail address removed)"
'pFriendlyName --> Original Songs from an upcoming Star"
'pBooEditMessage --> true if you want to edit message
' before mail is sent
' --> false to send automatically
'pWhoFrom --> "Susan Doe"
On Error GoTo EMailReport_error
'you can substitute acFormatSNP
' --> acFormatHTML
' --> acFormatRTF
' --> acFormatXLS
' --> acFormatTXT
' etc
on error goto Err_proc
DoCmd.SendObject _
pSendType, _
pObjectName, _
acFormatSNP, _
pEmailAddress _
, , , pFriendlyName _
& Format(Now(), " ddd m-d-yy h:nn am/pm"), _
pFriendlyName & " is attached --- " _
& "Regards, " _
& pWhoFrom, _
pBooEditMessage
Exit_proc:
Exit Sub
Err_proc:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " eMailObject"
'press F8 to find problem and fix
'comment or remove next line when code is done
Stop : Resume
Resume Exit_proc
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I must apologize, for some of this is "air-code" ... I
renamed parameters and added comments to code that I had
already written and tested ... if you see errors, I would
appreciate knowing what they are...
Warm Regards,
Crystal
Microsoft Access MVP 2006
remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day