I want to spread reports in pdf format by mail.
I have created a macro that works on my PC but when I send the document to the BCA the macro seems to fail.
On the server, the same mail-program is installed.
Don't know if this helps, but got this VBA from the BO helpdesk awhile ago... and it worked fine
Sub sendmail()
'This procedure allows you to attach a file
Dim Doc As Document
Dim Rep As Report
Dim i As Integer
Dim Send As String
Send = InputBox("Enter E-mail Address", "Send To"
Dim Subject As String
Subject = InputBox("Enter Subject", "Subject"
Dim Body As String
Body = InputBox("Enter Message to Client", "Client Message"
Set Doc = ActiveDocument
Doc.Refresh
For i = 1 To Doc.Reports.Count
Set Rep = Doc.Reports.Item(i)
Rep.ExportAsPDF ("C:\" & Rep.Name)
'Rep.ExportAsText ("C:\" & Rep.Name & ".txt"
Next i
Set OlkApp = CreateObject("Outlook.Application"
Set NewMail = OlkApp.CreateItem(olMailItem)
Set attachments = NewMail.attachments
For i = 1 To Doc.Reports.Count
attachments.Add ("C:\" & Rep.Name & ".pdf"
'attachments.Add ("C:\" & Rep.Name & ".txt" )
Next i
With NewMail
.To = Send
'.CC = " mail@somewhere.com <mailto:mail@somewhere.com> "
.Body = Body
.Subject = Subject
.Importance = 1
.Send
End With
you have to make sure that IIS/smtp is setup on your server correctly. it's really best to use cdonts for it rather than using an email client...more secure.
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.