sending a report to via email...

totomalas

Registered User.
Local time
Today, 09:05
Joined
Aug 8, 2009
Messages
15
I want to write a code for a button, so that once it is clicked, it sends a certain report to my boss via email... how can i do this? .. I really need your help...
 
Look up the docmd.SendObject function it works well with Outlook not sure about any thing else.
 
You could also use the Outlook Object library which will avoid the Microsoft anti-virus error prompt.
 
You could also use the Outlook Object library which will avoid the Microsoft anti-virus error prompt.

can you please explain to me how can i use this object, because I didnt know how to do it...thanks
 
There are many variations but this will give you the gist of it.

Public Sub SendeMail(oTo, oSub, oMsg As String)

On Error GoTo Err_Send

Dim objOutlook As Outlook.Application
Dim objeMail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.Application")
Set objeMail = objOutlook.CreateItem(olMailItem)

With objeMail
.Recipients.Add oTo
.Subject = oSub
.BodyFormat = olFormatRichText
.Body = oMsg
.Display ' .Send
'MsgBox " eMail sent to: " & dolookup("[Full Name]", "Users", "[eMail Address] = '" & oTo & "'"), vbInformation, "Outlook eMail"
End With

Exit_Send:
Set objOutlook = Nothing:
Set objeMail = Nothing

Exit Sub

Err_Send:
MsgBox Err.Number & vbLf & Err.Description, vbCritical, "eMail send"
Resume Exit_Send

End Sub

Make sure you have the Object Library loaded into any module in your database (Tools/References/Outlook Object Library)
 

Users who are viewing this thread

Back
Top Bottom