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!

multiple attachments 1

Status
Not open for further replies.

smiley0q0

Technical User
Feb 27, 2001
356
0
0
US
Is there a way to have access send an email with multiple attachments?
 
Smiley0q0,

I am trying to do the same thing...have Access send an email with more than 1 attachment. If you find out the answer, let me know too!

Thanks DonnaK
 
Try the code on this thread. It has worked for me and can be spiffed up with some loops and if...then's.
thread181-75403
jelwood01
 
this code works GREAT!!! ... but i have yet another question.. or 2... how do you attach it as a shortcut? i am using outlook. even a hyperlink would work, but i can't seem to figure that one out either? any ideas?

Thanks,
Smiley B-)
 
Smiley,

Are you looking to just point to the file location i.e. a shortcut? Depending on your network configuration this may or may not work. You can send a hyperlink that points to the location of a file on the network: C:\Access\Test.DOC or \\bravo\access\Test.DOC if the drives aren't named. I don't really like to send hyperlinks of files that reside on a network because not all drives/locations are shared and not all users may use the same drive map i.e. my D:\ might not be your D:\. If you want to place the attachment at the end of the document try this snippet:

objMail.HTMLBody = &quot;<HTML>&quot; & txt_body & &quot;<BR><BR></HTML>&quot;
objMail.Attachments.Add st_DocLocation, olByValue, Len(txt_body) + 100, &quot;Stuff&quot;

The piece &quot;Len(txt_Body)+100&quot; checks the length of the body text and moves the attachment out 100 more characters. This will place the attachment nicely at the end of the email.

Let me know if this helps or if you were looking for something else...

Thanks!

jelwood01
 
That should work, but unfortunatly i get an error saying something about it not supporting HTML... i am using outlook 97. for the people i will be sending this report to, i have it out on a drive that they all have access to, so that part won't be a problem, as for the hyperlink, how can i have it that they see &quot;Report Name&quot; and not the whole &quot;<\\X:\Reports\My Report.xls\>&quot;?

Smiley X-)
 
Here is the HTML to make a hyperlink:

<a href=&quot;
The first part of the tag {<a href=&quot; gives the actual address. In between those tags is the lable for the link, in this example Tek-Tips. Then the closing tag </a>. By the way these tags are called anchor tags.

For a location on a drive I would write it as such:
<a href=&quot;X:/Reports/My Report.xls&quot;>Check Out My Report</a>

Give this a shot and see if it works. If it doesn't we'll massage the HTML until it does!

jelwood01
 
yea i got it to work, i can't use html code for some reason, but &quot;file://X:\Reports\MyReport.xls&quot; works great.
Thank you for your help, i really do appreciate it.

Thanks,
Smiley. (-:
 
Hmm... No HTML code? Are you specifying .HTMLBody as opposed to .Body when you are building the email? That might be the root of the problem. All the same I'm glad it is working out.

Outlook is a pretty powerful tool and there are some neat things you can do with tasks, calendars, and emails through Access. At my company we update task lists and calendars out of Access, when there is a change in the system we push that change out to the users. Good luck with your code and let me know if you need any help!

jelwood01
 
it wouldn't let me specify HTMLBody, it didn't have the option, and when i just typed it in, it yelled at me and said there is an error. how do i set it so i can select it from the list? also i have gone into the object browser and seen attachment as a selection, but i haven't ever seen it in those little selection boxes... any ideas?
 
Do you want to forward on the code that you are using to create the email? Could be a couple of things... I'm assuming that you are using Access 97...
Let me know. Thanks!
jelwood01
 
sure.. here you go, and yea i am using 97.

Private Sub CmdSend_Click()
Dim appOut As Outlook.Application
Dim EMailOut As Outlook.MailItem
Dim MthYr As String
Set appOut = CreateObject(&quot;Outlook.Application&quot;)
Set EMailOut = appOut.CreateItem(olMailItem)
MthYr = Format(txtDate, &quot;mmmm - yyyy&quot;)

With EMailOut
.To = &quot;Jared Taylor&quot;
.CC = &quot;Makensey Murdock&quot;
.Subject = &quot;Waved Fees Report for &quot; & MthYr
.Body = &quot;The Waved Fees Report for &quot; & MthYr & &quot; has been updated.&quot; & vbNewLine & _
&quot;Please click on the link below to view.&quot; & vbNewLine & vbNewLine & _
&quot;file://X:\assetmgt\WavedFees.xls&quot; & vbNewLine & vbNewLine & _
&quot;If you have any questions or comments please feel free to contact Reporting by email or phone (57134)&quot; _
& vbNewLine & &quot;Thank You&quot;
.ReadReceiptRequested = False
.Display
End With

End Sub
 
Ah-Ha... I should have done my homework a little better! The reason behind your HTML woes is that Outlook 97 doesn't support HTMLBody as an object... Here is the link for the Map of the Outlook 97 object model:


My apologies on this one. I am running Outlook 98 and Outlook 2000, both of which support HTMLBody. Code looks good and the link comes out nicely and it does the job!

97 seems to only support plain text and RTF and I am not sure of a work around on that. If I find something, though, I'll let you know.

Thanks!

jelwood
 
aahh... so that's why... thank you for your help.

c ya...

Smiley :)I
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top