Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email using outlook express

Status
Not open for further replies.

m4moi

Programmer
May 22, 2004
5
0
0
CA
I want to be able to email 4 reports, all at once, to 3 people. I can use send object but then i would have to send each report separately. I want to use outlook express for the emailing and I want the user to just have to click on a command button when he/she is ready to email the reports. Any suggestions?
 
hi m4moi

outlook express is not "programable". it does not have a object model to work with. However, Outlook does have a object model to program from.

there are two possible path forwards.

1) use outlook express and send object to send your email. you can build the 3 email addresses you need into a variable. then.. use the variable in the send object command line for the email address.

(not tested...concept only)

strEmail = "some@nowhere.net"
strEmail = stremail & ", second@email.net"

docmd.sendobject ,,,,strEmail,,,,,

2) use Outlook object model to code from. This will give u more flexibility but involves more coding.

check out faqs: faq702-2921 and faq702-4509 for more ideas and examples.

HTH


Have A Great Day!!!, [bigglasses]

Nathan
Project Manager III
 
Thanks for your help Nathan. I am wanting to use Outlook Express though if I can. Send Object allows me to send to as many people as I want with one email but it only allows one attachment. So, for each report I need a separate email but at least I can send each report to multiple people with one email. Ideally, I would like to send all reports to all the people with one email.
 
Private Sub test_Click()
On Error GoTo Err_test_Click

Dim stdocname, stdocname1, stdocname2, stdocname3, stdocname4, stdocname5, stdocname6, stdocname7 As String
Dim olapp As New Outlook.Application
Dim olnamespace As Outlook.NameSpace
Dim olmail As Outlook.MailItem

Set olnamespace = olapp.getnamespace("MAPI")
Set olmail = olapp.CreateItem(olmailitem)
stDocName = "ReportName1"
stDocName1 = "ReportName2"
stDocName2 = "ReportName3"
stDocName3 = "ReportName4"
stDocName4 = "c:\My Documents\1.doc"
stDocName5 = "c:\My Documents\2.doc"
stDocName6 = "c:\My Documents\3.doc"
stDocName7 = "c:\My Documents\4.doc"

DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, stdocname4
DoCmd.OutputTo acOutputReport, stDocName1, acFormatRTF, stdocname5
DoCmd.OutputTo acOutputReport, stDocName2, acFormatRTF, stdocname6
DoCmd.OutputTo acOutputReport, stDocName3, acFormatRTF, stdocname7

With olmail
.to = test@me.co.uk
.Body = "Please find reports"
.Subject = "Testing sending out more attachments"
.Attachments.add stdocname4
.Attachments.add stdocname5
.Attachments.add stdocname6
.Attachments.add stdocname7
.ReadReceiptRequested = False
.Send

End With
MsgBox vbCrLf & "Your Reports have been sent", _
vbInformation + vbOKOnly, "Reporting:"

Exit_test_Click:
Set olapp = Nothing
Set olmail = Nothing
Exit Sub

Err_test_Click:
Select Case Err
Case Else
strerrmsg = strerrmsg & "Error #: " & Format$(Err.Number) & vbCrLf & vbCrLf
strerrmsg = strerrmsg & "Error Description: " & Err.Description & vbCrLf
MsgBox strerrmsg, vbInformation, "test_click"
Resume Exit_test_Click
End Select
End Sub


This will use your outlook as opposed to Outlook express, however, it allows you to attach more than one file.

the docmd functions are outputting the reports (stdocname-3 that you have created in access), to locations stated in stdocname4-7. When the email is attaching the files, it will go to the right location it was outputted to. Therefore, you will be required to change the value of the stdocname4-7 to a more appropriate folder on the correct drives.

hope this helps?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top