Email Reports and include images

  • Thread starter Thread starter RMLaundon
  • Start date Start date
R

RMLaundon

Guest
Have been browsing these boards for some time and they have been very useful.

I am now stuck with my latest project which is to email a single record with an image (photograph)

Emailing the report is fine but I am stuck on how to send the image. I notice that OLE objects don't like to travel via email so won't leave the database. As all my images are in one local folder and labelled the same as the user they relate to, is there some VB code I could use that I could add after sending the report which would pick out the image from this directory at the same time?

TIA
 
Hello RMLaundon,
How about using Microsoft Snapshot. Snapshot format saves both text and graphics format in your report. It is also
free so it is a great solution. The other method is to save in
PDF format where the client must have Adobe Arcobat Reader.
If you intend to save as PDF format you must have the Adobe
Acrobat Writer and is about $250.00.
Hope that helps you. Have a great day!
 
Use CDO and Mappi

If u use CDO extensions with mappi u can quickly and easly create an email with attachments

Heres one i made earlyer



Option Compare Database
Option Explicit

Dim oSess As Object
Dim oMsg As Object

Dim oRecipCC As MAPI.Recipient
Dim RepCol As New Collection

Public Function AddAttachment(Filename As String)
oMsg.Attachments.Add , , , Filename
End Function

Public Function AddRecipiant(Email As String)
Dim oRecipTo As MAPI.Recipient

On Local Error Resume Next
Set oRecipTo = oMsg.Recipients.Add
oRecipTo.Name = Email
oRecipTo.Type = ActMsgTo
oRecipTo.Resolve

RepCol.Add oRecipTo
On Local Error GoTo 0

End Function

Public Function SetSubject(Subject As String)
On Local Error Resume Next
oMsg.Subject = Subject
On Local Error GoTo 0
End Function
Public Function SetText(TXTStr As String)
On Local Error Resume Next
oMsg.Text = TXTStr
On Local Error GoTo 0
End Function

Private Sub Command2_Click()
Me.SetSubject "This is a test"
Me.SetText "Testing Testing 1 2 3, In case u haddnt realised this is a test."

Me.SendAndExit
End Sub

Private Sub Form_Load()


On Local Error GoTo ErrHdl

'Log on to the Session.
Set oSess = Nothing
Set oSess = CreateObject("Mapi.Session")


oSess.Logon '"MS Exchange Settings"
Set oMsg = oSess.Outbox.Messages.Add


ErrHdl:
On Local Error GoTo 0
End Sub
Public Sub SendAndExit()
' Send the message.
On Local Error Resume Next
oMsg.Update
oMsg.Send


'Log off the session.
oSess.Logoff

'Clear all the objects before exiting the procedure.

Set RepCol = Nothing
Set oMsg = Nothing
Set oSess = Nothing
DoCmd.Close acForm, "FrmBuildEmail", acSaveNo
On Local Error GoTo 0
End Sub


just copy this into a form (U will need to find and register COMCAT.DLL)

EDIT: i think im wrong about that dll, the one u need is Microsoft active messaging object library 1.1 (OLEMSG.DLL) :EDIT

:cool:ShadeZ:cool:
 
Last edited:
Both very good ideas and would work but the people I intend to send the reports by email to can just about cope with attachments so it would have to be a text email with the data from the form plus the image of the person the report is about.

is there a VB code that would allow me to link to for example:

c:\images\<username>.jpg ??

The function would go something like:

Select Record
Grab image from external directory
Send record and image by email to list of recipients

?????
 
Using my method will alow u to use code to create a email, add any body of text u wish + any number of required attachments,

just use

AddAttachment - to add an attachment (the file u want to send)
SetText - to fill the body of text
SetSubject - to give the email a subject
AddRecipiant - to fill in the recipiant

just call these functions from your code and your away

EDIT:U can add as many recipiants as u like :EDIT


:cool:ShadeZ:cool:
 

Users who are viewing this thread

Back
Top Bottom