help?

Hi listers,

I need to find a sample of a custom macro, something to send email… Anyone have a snippet I could look at, see what I am getting into?? Today?

Also, any thoughts about how to manage recipients? The names may have nothing to do with who the report goes to… Like I may notify a VP that an order for 1million dollars has come in, but I would send the report to Finance… make sense? Like refresh to ______, custom macro that emails ______

Any input would be great,
Brent


Listserv Archives (BOB member since 2002-06-25)

Listers,
If any of you are sending the macro directly to Brent,please send me too. I am also in need of this.

Thanks,
Durgesh

Brent Wrote :

Hi listers,

I need to find a sample of a custom macro, something to send email… Anyone have a snippet I could look at, see what I am getting into?? Today?

Also, any thoughts about how to manage recipients? The names may have nothing to do with who the report goes to… Like I may notify a VP that an order for 1million dollars has come in, but I would send the report to Finance… make sense? Like refresh to ______, custom macro that emails ______

Any input would be great,
Brent


Listserv Archives (BOB member since 2002-06-25)

I found one sample via BO - more would still be helpful…

Brent

Sub EmailCsv()
’ Export the Data Providers as Comma Separated Values (.CSV) files Dim i As Integer
Dim DPName As String
Dim test As Boolean

For i = 1 To ThisDocument.DataProviders.Count DPName = “C:” + DataProviders.Item(i).Name test = DataProviders.Item(i).ConvertTo(boExpAsciiCSV, 1, DPName) Next i

’ Email the CSV files
Dim Out As Outlook.Application
Dim Mess As Outlook.MailItem
Dim DocumentName As String

Set Out = CreateObject(“Outlook.Application”) Set Mess = Out.CreateItem(olMailItem)
DocumentName = ThisDocument.Name & “.rep”

Mess.Subject = “Data of Business Objects report '” & DocumentName & “’” Mess.Body = "Please find the new data of " & DocumentName Mess.To = “user1@Mycompany.com;user2@mycompany.com” Mess.Save
Set myAttachments = Mess.Attachments
For i = 1 To ThisDocument.DataProviders.Count Set myAttachment = myAttachments.Add(“C:” + DataProviders.Item(i).Name + “.csv”, olByValue, 1, "Data of DP # " & i) Next i
Mess.Send

For i = 1 To ThisDocument.DataProviders.Count Kill “C:” + DataProviders.Item(i).Name + “.csv” Next i
End Sub


Listserv Archives (BOB member since 2002-06-25)

Thanks Brent!!
But It will work for Outlook as Mail application.If I have Lotus notes>>What changes
I need to do to the code???

Regards,
Durgesh

I found one sample via BO - more would still be helpful…

Brent


Listserv Archives (BOB member since 2002-06-25)

If you are running the script through Broadcast Agent, it is important that you use MAPI instead of Outlook.
Here is a sample script from Business Objects that uses MAPI:

Sub CreateOutlook()
Dim objSession As MAPI.Session ’ Local
Dim objMessage As Message ’ local
Dim objRecip As Recipient ’ local
On Error GoTo error_olemsg

Set objSession = CreateObject(“MAPI.Session”) objSession.Logon profileName:=“Alex kellogg”, newSession:=True, showDialog:=False

If objSession Is Nothing Then
Err.Raise 10, “MA MACRO”, “must first log on; use Session->Logon” Exit Sub
End If

Set objMessage = objSession.Outbox.Messages.Add If objMessage Is Nothing Then
Err.Raise 11, “MA MACRO”, “could not create a new message in the Outbox” Exit Sub
End If

With objMessage ’ message object
.Subject = “test envoi mail aprËs process BcA” .Text = “Text du Body”
.Text = " " & “+ autre text” ’ add placeholder for attachment

Set objRecip = .Recipients.Add
With objRecip
objRecip.Name = “Olivier DESSE”
objRecip.Type = CdoTo
objRecip.Resolve
End With

Set objRecip = .Recipients.Add
With objRecip
objRecip.Name = “akellogg@businessobjects.com” objRecip.Type = CdoCc
objRecip.Resolve
End With

.Update ’ update message to save attachment in MAPI system .Send showDialog:=False
End With
objSession.Logoff
Exit Sub

error_olemsg:
'MsgBox "Error " & Str(Err) & ": " & Error$(Err) Err.Raise 13, “MA MACRO”, "Error " & Str(Err) & ": " & Error$(Err) Resume Next
End Sub

I hope this helps,

Helen Beisgen
InfoSol Inc.


Listserv Archives (BOB member since 2002-06-25)

One snag,

Note:

  1. This example uses the Outlook object model. In the VBA editor, select Tools > References and add ‘Outlook 98 type library.’ 2. This method requires the user to manually modify the list of people the mail will be sent to. <<

in my VBA editor, I can not get to references - anyone know what may be that cause? I have used VB before, but I am not proficient (evidently) -

I just want to see that I can do this once, would make my week…

Humbly,
Brent


Listserv Archives (BOB member since 2002-06-25)