Attachments to Email with SendObject

A

ant1983

Hi Guyz,

I have a form (tblBooking subform1) (I know the naming is a mess!) - On that
form i have a button cmdEmailInvite which opens a report
rptTrainingConfirmation which runs off a query qryTrainingInvites.

Basically the cmdEmailInvite is a SendObject so sends that report to an
email as a pdf.

My problem is that i need other attachements on that email to and in another
post somene said Access cant attach external files to an email. Now firstly,
its not really an external file as the attachements i want attached are saved
in my database in another table as an attachemnt field type but anyway...

REgardless, i thought of another way to get around this.

I thought i could create Outlook Templates with my attachemnts saved in the
templates and then refer to that template in my code - would that work?

So i saved the template at the folowing location:

C:\Users\Qbit - Wayne\Desktop\FNB Map and ISHCM Reading.oft

Then i went to the code and changed it to:

Private Sub cmdEmailInvite_Click()
On Error GoTo Err_cmdEMailInvite_Click

Dim stDocName As String

stDocName = "Training Confirmation"
DoCmd.SendObject acReport, stDocName, acFormatPDF, txtEmail, "", "",
"Training Confirmation: " & txtCourse & " on " & dateStartDate & " to " &
dateEndDate, "Dear Delegate Blach Blah" , ,
C:\Users\Qbit - Wayne\Desktop\FNB Map and ISHCM Reading.oft

Exit_cmdEMailInvite_Click:
Exit Sub

Err_cmdEMailInvite_Click:
MsgBox Err.Description
Resume Exit_cmdEMailInvite_Click

End Sub

It doesnt work though. Brings up a "Compile Error - Syntax Error"

So basically my questions:

1 - Whats wrong with my code?
2 - Would the whole template idea work?

My 3rd question is basically if the above isnt possible. Somene said in
another post that i could use outlook automation. I have no idea what that
means - they referred me to
http://www.devhut.net/index.php?lang=en&pid=0000000013#OutlookAuto so...
3 - Where does that code go? on my command button or somewhere in Outlook?

Thanks a ton!

ant1983
 
D

Daniel Pineault

You will need to switch to outlook automation, or another alternate method as
sendobject only allows one attachment.

Outlook automation is simple, and you can get a sample function to work with
at:

http://www.devhut.net/index.php?lang=en&pid=0000000013#OutlookAuto

Save your attachments to the hard drive, soo generate your pdf first, then
simply use the above mentioned e-mail routine to send your message.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
A

ant1983

Thanks Daniel. You've mentioned that before and like i saidin my post i have
no idea what to do with that code. Ive asked some other questions. Can
anyone assist? Thanks.
 
D

Daniel Pineault

We are all here to help. What do you not understand or know to do?

It is a standard function with input variables very similar to those used in
the sendobject().

If you explain what you need further help with, we will be more than willing
to assist. One way or another, sendobject will not do what you need it to do
in your scenario.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
G

Gina Whipp

Ant1983,

The code on that page must copied into a module and then named anything
expect the same name as the function. Is that the part you are not
understanding?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
Thanks Daniel. You've mentioned that before and like i saidin my post i
have
no idea what to do with that code. Ive asked some other questions. Can
anyone assist? Thanks.
 
A

ant1983

LOL - Yeah i didnt quite get that part :)

So, where do i find the modules? Im running 2007.
 
A

ant1983

OK - I found the modules (2007 is sooo different!)

i copied that code in a new module and then saved it as modSendEmail. What
do i do now?

1 - Do i amend the code to what is appropriate to my code?
2 - Do i attach it to some kind of button or something?
 
G

Gina Whipp

ant1983,

1. There is nothing to amend.
2. It would be attached to a button

Do you save your documents to a .PDF? And where are they on your hard
drive? I am also sensing that your knowledge of VBA is limited, is this
true?

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

OK - I found the modules (2007 is sooo different!)

i copied that code in a new module and then saved it as modSendEmail. What
do i do now?

1 - Do i amend the code to what is appropriate to my code?
2 - Do i attach it to some kind of button or something?
 

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