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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email using VBA

Status
Not open for further replies.

bo5i

Programmer
Jul 22, 2002
36
US
Hi, I am aware of sending email through VBA as an attachment in whatever format. But now i need to send email with report data being email body instead of an attachment.

Any ideas ?

Thanks
 
Get the html for that report and put it into your email's body, should work and be less expensive ;-) Stick to your guns
 
You can get it to run from vba - I have integratyed it with LOtus Notes quite easily - what e-mail system are you using this code works with LOtus Notes

Private Sub documentopen()
Call SAVE

Dim Maildb As Object 'the mail database
Dim username As String
Dim maildbname As String
Dim maildoc As Object
Dim attachme As Object
Dim session As Object
Dim embedobject As Object
Dim mytime As String
Dim recipient As String
Dim subject As String
Dim attachment As String
Dim BodyText As String

recipient = "Customer Support PROBATE-SERVICES/HBEU/HSBC"
subject = "PSM Diary"
attachment = "C:\My Diary.rep"
BodyText = "Diary"
Set session = CreateObject("Notes.NotesSession")
username = session.username

Set Maildb = session.GETDATABASE("", maildbname)
If Maildb.ISOPEN = True Then

Else
Maildb.OPENMAIL
End If
Set maildoc = Maildb.CREATEDOCUMENT
maildoc.Form = "Memo"
maildoc.sendto = recipient
maildoc.subject = subject
maildoc.Body = BodyText


If attachment <> &quot;&quot; Then
Set attachme = maildoc.CREATERICHTEXTITEM(&quot;Attachment&quot;)
Set embedobject = attachme.embedobject(1454, &quot;&quot;, attachment, &quot;Attachment&quot;)


End If

maildoc.PostedDate = Now()
maildoc.send 0, recipient

Set Maildb = Nothing
Set maildoc = Nothing
Set attachme = Nothing
Set session = Nothing

MsgBox &quot;Mail sent to&quot; & recipient & &quot;re:&quot; & subject


Application.Quit




End Sub

This auto sends a report when it is reopened and refreshed - the code calls a module called save which refreshes and saves the report.

The attachment is created by the save module, give it a ras....
 
We cannot go for mail component due to budget constraints. We are using Outlook as the default email application. How to render the report content and put it into email body. I am able to send the report as an attachment.

I appreciate if you guys can throw some more light on this.

Thanks
 
You can use ASPEmail ( to send report from VBA with Broadcast Agent instead of Outlook.
Seems to be dedicated to ASP but works fine in VBA. Stick to your guns
 
Yes, code has to be changed. As of now i am using BO SDK methods to generate an attachment. But how to capture the report data and display it as HTML int he email body.

Its decided to use only Outlook as email system.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top