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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I email a bound OLE object as an attachment?

Status
Not open for further replies.

perfessor

Programmer
May 12, 2000
5
US
I have a deduction tracking database, and the client wants to be able
to attach a document (Word/Excel/Other), and then at some later time,
be able to email that document to someone.
I have the table on our SQL server, with the field as an image
datatype. It attaches in Access as an OLE Object.
I already have a routine to email x number of attachments that takes
files directly from my system.

I need to know if it is possible to output the OLE object to it's
original file type, so I can send it from there. If so, is there a way
to programmatically get the file type so I can save it with the correct
file name extension?

Alternatively, how would I send that object (or objects) directly from
access?

We are on Outlook.

Thanks!
Rik


 
This will send To, CC and BC as well as Subject, Message, and Attachment
You need 6 text boxes or variables which match the following:
txtMainAddresses
txtCC
txtBCC
txtSubject
txtBody
txtAttachment

Put this in your Module
------------------------------
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
------------------------------
put this in a command button
------------------------------
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stext As String
Dim sAddedtext As String
If Len(txtMainAddresses) Then
stext = txtMainAddresses
End If
If Len(txtCC) Then
sAddedtext = sAddedtext & "&CC=" & txtCC
End If
If Len(txtBCC) Then
sAddedtext = sAddedtext & "&BCC=" & txtBCC
End If
If Len(txtSubject) Then
sAddedtext = sAddedtext & "&Subject=" & txtSubject
End If
If Len(txtBody) Then
sAddedtext = sAddedtext & "&Body=" & txtBody
End If
If Len(txtAttachment) Then
sAddedtext = sAddedtext & "Attach=" & Chr$(34) & Me!txtAttachment & Chr$(34)
End If

stext = "mailto:" & stext

If Len(sAddedtext) <> 0 Then
Mid$(sAddedtext, 1, 1) = &quot;?&quot;
End If

stext = stext & sAddedtext

' launch default e-mail program
If Len(stext) Then
Call ShellExecute(Me.hwnd, &quot;open&quot;, stext, vbNullString, vbNullString, SW_SHOWNORMAL)
End If

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

------------------------------

 
Thanks Doug, but I already have a function for sending attachments. What I need is to figure out how to send an OLE bound object that I have on a Sql server.

I can't even figure out how to save the OLE object (BMP, JPG, Excel, Doc, whatever they want to attach) back to the hard drive without opening up the associated application and doing it from there.
The problem with that is that I have my program generating a cover sheet, and emailing that. If there were two documents scanned and imported into the bound column, they would have to go out as separate emails.
Thanks,
Rik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top