In order to make things easier, from communication point of view, I created this "New E-mail form" in my app. It automatically generates To,Cc, Subject, Body Text depending on the day I send the e-mail in.
When pressing Send, first it makes sure that the required fields are filled and then it sends the message using background outlook (the red label warns users that they have to make sure Outlook is opened.
Is it possible for it to automatically attach the corresponding reports instead of asking E-mail recipients to run and have them printed?
I mean, I wish I was able to attach reports that are created within app itself, based on the content in the E-mail Screen.
E.G. E-mail Luni (Monday E-mail) - sends an e-mail based on hidden cbo's values. The screen "knows"exactly what reports should create but I have no idea how to attach and then have them moved as "e-mail attachments" in outlook.
The called function on send is:
Public Function Email1(ByVal pvTo, ByVal pvCc, ByVal pvSubj, ByVal pvBody, ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.TO = pvTo
If Not IsNull(pvCc) Then .CC = pvCc
.Subject = pvSubj
If Not IsNull(pvBody) Then .Body = pvBody
If Not IsEmpty(pvFile) Then .Attachments.Add pvFile, olByValue, 1
.Send
End With
Email1 = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function
How do I define pvFile as two reports that auto generates as PDF?