Attachment with followhyperlink mailto

R

Rli

Hi all,
I have found out that one can open the users mailbox and prepare a mail to
send with code like this:

Dim sendstring As String
If Nz(Me.[envoyera], "") <> "" Then
sendstring = "mailto:" & Me.[envoyera].Value
If Nz(Me!envoyerCC, "") <> "" Then
sendstring = sendstring & "?CC=" & Me!envoyerCC.Value
End If
If Nz(Me!envoyerBCC, "") <> "" Then
sendstring = sendstring & "&BCC=" & Me!envoyerBCC.Value
End If
If Nz(Me!Sujet, "") <> "" Then
sendstring = sendstring & "&Subject=" & Me!Sujet.Value
End If
If Nz(Me!bodytexte, "") <> "" Then
sendstring = sendstring & "&Body=" & Me!bodytexte.Value
End If
Application.FollowHyperlink sendstring
End If


This works just fine, but does anyone know how to attach a file with this
method when the filename to attach is known?
(i tried also the sendobject method, but prefer not to because it implies a
reference to the outlook library, not always present for all users)
 
D

Dirk Goldgar

Rli said:
Hi all,
I have found out that one can open the users mailbox and prepare a
mail to send with code like this:

Dim sendstring As String
If Nz(Me.[envoyera], "") <> "" Then
sendstring = "mailto:" & Me.[envoyera].Value
If Nz(Me!envoyerCC, "") <> "" Then
sendstring = sendstring & "?CC=" & Me!envoyerCC.Value
End If
If Nz(Me!envoyerBCC, "") <> "" Then
sendstring = sendstring & "&BCC=" & Me!envoyerBCC.Value
End If
If Nz(Me!Sujet, "") <> "" Then
sendstring = sendstring & "&Subject=" & Me!Sujet.Value
End If
If Nz(Me!bodytexte, "") <> "" Then
sendstring = sendstring & "&Body=" & Me!bodytexte.Value
End If
Application.FollowHyperlink sendstring
End If


This works just fine, but does anyone know how to attach a file with
this method when the filename to attach is known?
(i tried also the sendobject method, but prefer not to because it
implies a reference to the outlook library, not always present for
all users)

SendObject most definitely does *not* imply a reference to the Outlook
library -- it uses MAPI to create and send a mail message, and will
happily use the user's default mail client -- Outlook Express, in my
case -- assuming they have one and it's MAPI compliant. The user need
not have Outlook installed, but they do need to have a default mail
client, even for a mailto: hyperlink to work.

On the other hand, you can't use SendObject to attach a non-Access
object. So if you want to send a message with an attachment that isn't
one of the objects in your database, you have to use something else.

I've read some web pages referring to an &attachment option for a
mailto: hyperlink, but I haven't been able to make it work. I generally
use MAPI code to send such messages. See Tony Toews' Access Email FAQ
page, especially this subpage:

http://www.granite.ab.ca/access/email/mapi.htm
 
R

Rli

Hello Dirk, thank you for replying and setting me wright on no outlook lib
needed for Sendobject. I was mistaken...
My case is that I want to send a zipped database backend file by mail.
In one button on a form i first release the backend mdb, then zip it and
then want to send it to a predefined email address. So the file i want to
send is not a access object and sendobject can't be used.

I looked at the URL you gave, the 'simple mapi' link seems to be the
solution. But i am no expert on programming vba. So can you please tell me
how to use the .cls, .bas and .vbp files contained in the downloadable zip on
this link?
How to implement this in a forms button code?

Thanks anyhow..

Rob

:
 

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