Not directly, but you could have the data report export as an html file and then email it as an attachment. I had to format and attach an excel file and send an automatic email
see code below:
Private Sub cmdSend_Click()
On Error GoTo ErrHand
DoEvents
'create and send email
Dim cdoFolder As MAPI.Folder
Dim cdoMessages As MAPI.Messages
Dim cdoMessage As MAPI.Message
Dim cdoRecipients As MAPI.Recipients
Dim cdoRecipient As MAPI.Recipient
StartMail:
Set CDOSession = New MAPI.Session
CDOSession.Logon "", , True, True, frmEmail.hwnd, False
Set cdoFolder = CDOSession.Outbox
Set cdoMessages = cdoFolder.Messages
Set cdoMessage = cdoMessages.Add
Dim cdoAttachments As MAPI.Attachments
Dim cdoAttachment As MAPI.Attachment
Set cdoRecipients = cdoMessage.Recipients
Set cdoRecipient = cdoRecipients.Add
cdoRecipient.Name = RS!emailadd
cdoRecipient.Resolve
.ReadReceipt = True
.Send (True)
End With
CDOSession.Logoff
Unload Me
Exit Sub
ErrHand:
Select Case Err.Number
Case -2147221233
MsgBox "Invalid Profile Selected.", vbCritical + vbOKOnly + vbApplicationModal, "Error"
Resume StartMail
Case -2147221223
MsgBox "Outlook is currently open or being used." & _
vbNewLine & "Please close Outlook and try again.", _
vbOKOnly + vbInformation + vbApplicationModal, "Close Program"
Resume StartMail
Case Else
Err.Raise Err.Number
End Select
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.