How can I alter my code to send an attachment?

  • Thread starter AbraAbraCadabra
  • Start date
A

AbraAbraCadabra

Here is the code I am using to send mail...
With objEmail
.From = Chr(34) & "Name" & Chr(34) & "(e-mail address removed)"
.To = strToArray(x)
.Subject = strSubject
.HtmlBody = strBody
.Send
End With


How can I send an attachment?
Is it something like this...?
.attachment="c:\file.txt"
 
R

Ron2006

that is if you are using the sendobject command and I am not sure that
is what you are doing

Have you tried adding the following to your code:

.attachments.Add ReportDir & exportName ' point to the full
address of attachment here
' There can be multiple of the above
 
T

Tom Wickerath

Hi AbraAbraCadabra,
Tom, if I read your thread correctly, it states it is not possible to send an
attachment using the method I am using.

What method are you using? You only provided a code snippet. If you are
using SendObject, I don't think that it supports HTML (ie. .HtmlBody =
strBody), so I just assumed you were using Outlook. It is possible to attach
an Access object (table, query, report) using SendObject, but I'm not so sure
that this method supports attaching an external file. Check it out in the
Help file, but I'm pretty sure that it only supports attaching an Access
object.


Tom Wickerath, Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
A

AbraAbraCadabra

Here is what I am using...

Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = Chr(34) & "John" & Chr(34) & "(e-mail address removed)"
.To = "(e-mail address removed)"
.Subject = "Test"
.TextBody = "Test"
.Send
End With
Set objEmail = Nothing
 
T

Tom Wickerath

I can't say that I've ever used CDO, so I'm afraid you're on your own, unless
someone else wants to contribute to this thread. I would search the Knowledge
Base for samples:

http://support.microsoft.com/search...dt=0&comm=1&ast=1&ast=2&ast=3&mode=a&x=15&y=9

and also MSDN:
http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=cdo

This one looks promising:
http://msdn.microsoft.com/library/d...1d-c2bb-41ad-8a47-15deb4dbc8a8.asp?frame=true

Finally, if you don't have any luck there, you can always try a Google
Groups Advanced Search.


Good Luck,

Tom Wickerath, Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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