473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SendObject and Filename Change

The following module, which works just fine, is designed to mass
e-mail info to individual projects but the attachment is always
"rptexpendituredetail.xls".

Is there any way to change the attachment's filename each during each
loop so each project can receive a uniquely named file??

FYI, rptexpendituredetail is the name of the Access report that
filters the data for each project based on a query.
===============================================

Private Sub cmdMassEmail_Click()
Dim stDocName As String
Dim ProjManager As String
Dim ProjName As String
Dim rst As Recordset
stDocName = "rptexpendituredetail"

For i = 0 To ProjNumber.ListCount - 1

ProjectNumber = ProjNumber.ItemData(i)

Set rst = New Recordset
rst.Open "select projectmanager, projectname from [1641
Projects] where ProjectNumber = " & ProjectNumber,
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not IsNull(rst("ProjectManager")) Then
ProjManager = rst("ProjectManager")
ProjName = rst("ProjectName")
DoCmd.SendObject acReport, stDocName, acFormatXLS,
ProjManager, , , SubjectLine & " - " & ProjName & " (" & ProjectNumber
& ")", "Attached is your EDR for project number " & ProjectNumber,
False
End If
rst.Close
Next i
End Sub
========================
Nov 13 '05 #1
1 3500
dt*******@comcast.net (D.Tulenson) wrote in message news:<e6**************************@posting.google. com>...
The following module, which works just fine, is designed to mass
e-mail info to individual projects but the attachment is always
"rptexpendituredetail.xls".

Is there any way to change the attachment's filename each during each
loop so each project can receive a uniquely named file??


I got the following code sample from OutlookCode.com:

Sub NewMailMessage()
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "Training Information for October 1997"
'Create some body text.
.Body = "Here is the training information you requested:" &
vbCrLf

'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add("mi****@imginc.com")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address.", vbInformation
Exit Sub
End If
End With

'Attach a file as a link with an icon.
With .Attachments.Add _
("\\Training\training.xls", olByReference)
.DisplayName = "Training info"
End With

'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

The corresponding code for Access is almost identical. Besides
allowing for different attachment names on each loop, this technique
looks like it is more robust than using SendObject in general. Also,
get to know the difference between early and late binding for
Automation Objects. Make sure your References include the Outlook
Object Model.

James A. Fortune

MIME is a series of specifications that describe how to represent
binary data as text so that they may be sent via text-based electronic
mail. --- David Wood, Programming Internet Email, O'Reilly 1999
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jay Bienvenu | last post by:
I'm having a very strange problem that currently defies explanation. I use the code below to send a status report to a client. The intent is to send the user the report via fax using WinFax and/or...
0
by: Bret Shortall | last post by:
Using the SENDOBJECT action command in a Macro works fine if you hard code in their email address. SENDOBJECT TO bret@emailaddress.com SUBJECT This is the Subject line...
1
by: Lauren Quantrell | last post by:
I am using the following to attach a report, in HTML format to an e-mail using Access2K: DoCmd.SendObject acSendReport, "myReportName", acFormatHTML, , , , "mySubject", "myTExtBody", True,...
8
by: Andy Kasotia | last post by:
Warning message in Outlook 2003 while using SendObject. When i try to use sendobject to send an email, a warning massage pops up, saying that "Outlook is trying to send an email.......if this is...
3
by: Fred Zuckerman | last post by:
Hello All, I had written a quick email procedure for a client that uses DoCmd.SendObject. However they have the SR-1 version of Access 2K. They do not have the SP-3 upgrade. The procedure does...
2
by: Andy_Khosravi | last post by:
I posted this question about two days ago, but for some reason it never actually got put up. I couldn't' find it with searches, so I am re-posting it now. I apologize if this is a double post. ...
2
by: John | last post by:
User needs to be able to send an emailmessage from an emailaccount other than his own. The rights are set so that he is authorised to do so. The sendobject doesn't seems to give the option to set a...
0
by: (PeteCresswell) | last post by:
Another thread got me going on SendObject. Works like a champ for emailing somebody a .SNP of a report as in: DoCmd.SendObject acSendReport, "rptMaturities", "Snapshot Format", "pCresswell", ,...
4
by: Ken OHanlon | last post by:
I have an Access 2003 question. It is about using SendObject and/or OutputTo. I want to be able to send an e-mail (Invoice) to my customer each and every time one of his employees comes into the...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.