Sending emails via OutLook with VBA and ConvertReportToPDF (Lebans

J

Jay

I am using the code below to export a report to pdf - using Lebans code as
above then attach this pdf to a new email in Outlook
The problem is that if I use the Display email option - if the user then
trys to click back into the database - the system will freeze and display
the message - "This action cannot be completed because the other application
is busy - choose switch"etc...
If I choose the send option - the Outlook security message appears with the
another application is trying to send emails from your Outlook account etc
warning

Does anyone know a solution of either (or both would be great) of these
problems

Segment of code as follows...

Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this example.
blRet = ConvertReportToPDF("rptOnLineAssessments_Form_Send", vbNullString, _
strFileName, False, False, 0, "", "", 0, 0)
' To modify the above call to force the File Save Dialog to select the name
and path
' for the saved PDF file simply change the ShowSaveFileDialog param to TRUE.


'Code to attach snapshop and send
Dim O As Outlook.Application
Dim M As MailItem
Dim strMsg As String
Dim UserName As String

UserName = fOSUserName()
DefaultText = "Please find attached Online Assessment Booking Form" _
'
Set O = New Outlook.Application

Set M = O.CreateItem(olMailItem)



'M.UserProperties.Add "from", olText, From, olText
M.To = "EmailAddressName"
M.Subject = "Online Assessment Booking Form " & txtDate & " " &
strCampus & " " & txtAwardBody & " " & strSpecReq & " OLA No - " & intOLANo
M.Body = DefaultText
M.Attachments.Add strFileName

M.Display True 'Lets you see the message created!!!

'M.Send 'This will send the message

Set M = Nothing
Set O = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top