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!

e-mail reports 2

Status
Not open for further replies.

jeet7

IS-IT--Management
Oct 8, 2003
1
0
0
CA
i would like to know hoe to e-mail reports from Access database automatically.
 
Are you using Outlook or Lotus Notes?

If you are using Lotus Notes, the SendObject command will not work.

Let me know, I can post the code to use Lotus Notes if you need it.

 
I'm not the original poster, but I have a db that I need to email reports from and we use Lotus Notes - can you post the code to use Lotus Notes...p. l. e. a. s. e.

thank you!
 
Since you asked so nicely, I suppose.

Note: If you are attaching the results of a report to the e-mail, you must output it to a file and attach the file.


Function SendTPAEmail(strRecipient As Variant, strPath1 As String)

Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesDocument As Object
Dim strText As String
Dim strMsg As String
Dim varRecipient As Variant

Dim objAttach As Object
Dim objEmbed As Object

Set objNotesSession = CreateObject("Notes.Notessession")
Set objNotesDatabase = objNotesSession.GETDATABASE("", "")
Call objNotesDatabase.OPENMAIL

Set objNotesDocument = objNotesDatabase.CREATEDOCUMENT
strText = ""

varRecipient = Split(strRecipient, ";", -1)

Call objNotesDocument.REPLACEITEMVALUE("SendTo", varRecipient)
Call objNotesDocument.REPLACEITEMVALUE("Subject", "This is an Email")
Call objNotesDocument.REPLACEITEMVALUE("Body", strText)

Set objAttach = objNotesDocument.CREATERICHTEXTITEM("Attachment")
Set objEmbed = objAttach.EMBEDOBJECT(1454, "", strPath1, "Attachment")

objNotesDocument.SAVEMESSAGEONSEND = True
Call objNotesDocument.SEND(False)
Set objNotesSession = Nothing

End Function
 
Ok, not to sound stupid, but where do I put this code, I'm assuming somewhere in the report but where?
 
on your form - try this - make a command button - then when the wizard starts, press cancle. Right click on the button and you shoould have three options - macro builder, expression builder, and code builder. Use code builder,. This opens the VB editor - paste your code there -in the on_click section.

PDUNCAN - MEMPHIS, TN

When I die, I want to die like my grandfather-- who died peacefully in
his sleep. Not screaming like all the passengers in his car.
 
Dear mkov,

I have no need for your code, but...

since you took the time to anwser, and no one else has done this, [blue] I give you a star!! [black]

Hap [2thumbsup]


Access Developer [pc] - [americanflag]
Specializing in Access based Add-on Solutions for the Developer
 
sdk2726,

What pduncan says is exactly what I usually do. You would also put in a module and call it.


Hap007,

Thank You, it is greatly appreciated.
 
is putting it in a mudule and calling it an either/or - I usually dont do that, but then again, I dont know much about this - except for what I have learned here!

PDUNCAN - MEMPHIS, TN

When I die, I want to die like my grandfather-- who died peacefully in
his sleep. Not screaming like all the passengers in his car.
 
The only reason that I put it in a module and call is because I will use the code from different locations within the same database.

It is much easier (and cleaner programming) to just call it and pass values to it instead of rewriting it each time.

But everyone has their own programming habbits, some good, some bad. If it works stick with it.
 
makes sense to me - I have never done that, but it does seem reasonable and like the "right thing to do." If you placed this into a module named "Mail" how would you reference this module from the on_click of a command button?

PDUNCAN - MEMPHIS, TN

When I die, I want to die like my grandfather-- who died peacefully in
his sleep. Not screaming like all the passengers in his car.
 
You don't call the module itself, it is only a place to "store" code. You have to call the function or sub name, you can have a lot of functions or subs in 1 module.

Private Sub Command37_Click()

Function/SubNameHere

End Sub

OR

Private Sub Command37_Click()

Call Function/SubNameHere

End Sub
 
thanks - always wondered ho to do that - you make it sound easy. Star to ya!

PDUNCAN - MEMPHIS, TN

When I die, I want to die like my grandfather-- who died peacefully in
his sleep. Not screaming like all the passengers in his car.
 
Thanks to all especially mkov - you are so helpful. This site has saved me - again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top