Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro for sending reports by mail 1

Status
Not open for further replies.

Gryson

Programmer
Dec 5, 2001
2
0
0
BE
Hoi,

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.

Any suggestions or new macro's ?
 
whats the platform ur BCA running on ?

Broadcast agents on Unix are not supported to run any VBA scripts and macros.
 
It is a windows Nt platform, I think, not Unix that I'm certain because simple scripts (deleting files, exporting as pdf,...) I can run.
 
make sure the same profile is being used on the server(one on ur m/c)
 
Did you ever get this to work, and if so, how did you get around the log in PW prompt?
 
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 = &quot; mail@somewhere.com <mailto:mail@somewhere.com> &quot;
.Body = Body
.Subject = Subject
.Importance = 1
.Send
End With

End Sub
 
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.
 
I created macro suggested by typeslowly and saved with this report, but how to run macro automatically once you open the document?
any idea?
 
Set it to execute on open (from Visual Basic Editor) Stick to your guns
 
It may be funny to ask how to set it to execute on open, butI am gonna ask you, coz I am zero at VBA and macros.

Please gimme your advice.

TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top