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!

Send a report via Notes

Status
Not open for further replies.

kev747

Technical User
Jan 30, 2003
68
0
0
AU
Hey guys,
Wonder if someone could give me a little advice on how to do this.
I can get a report I've created to insert itself into a blank e-mail in Notes by way of a commend button, but it is really annoying how the "Select Format" window appears every time I want to email a report. Is there anyway I can have this default to the HTML option in the format window each time, and thus not ask the question?

Also, is it possible for Access to fill in the recipients email address in the "To" field of the email in Notes with a predetermined address?

Thanks for any help offered.

Kev.


This is a politically correct signature, due to constant whinging about my previous signature.
Long live the fun police.
 
Kev,

Below is some code that I have inherited and modified for my purposes. I am not sure where it originally came from but have seen several versions on other sites.

I use this code to pickup an attachement that I have created by exporting a report/query. I hope it helps.

One point - on our system the e-mail address has to be perfect as the code does not check that it is valid prior to sending.

Code:
Function TestMail()
Dim TestNames(2) As String  '(2) As Variant
Dim attachement As String
Dim fileName(1) As String

TestNames(0) = "Address 1"
TestNames(1) = "Address 2"
TestNames(2) = "Address 3"
fileName(0) = "c:\temp\rd201.txt"
fileName(1) = "c:\temp\rd210.txt"

SendNotesMailmultiAttach TestNames(), "Test Mail", fileName(), "Just testing an Automailer routine", True, True, TestNames()
'
End Function

Sub SendNotesMailmultiAttach(addressee() As String, subject As String, Attachment() As String, BodyText As String, SaveIt As Boolean, RtnRec As String, ParamArray ccRecipient())
Dim y As Integer, z As String
Dim x
Dim recip(50) As String
Dim Maildb As Object 'The mail database
Dim Username As String 'The current users notes name
Dim MailDbName As String 'The current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)


Set Session = CreateObject("Notes.NotesSession")
Username = Session.Username
MailDbName = Left$(Username, 1) & Right$(Username, (Len(Username) - InStr(1, Username, " "))) & ".nsf"
'MailDbName = "mail7\odmu.nsf" to uses a specific mail box

Set Maildb = Session.GETDATABASE("", MailDbName) ' you may need to populate the Server name where I have ""

If Maildb.ISOPEN = True Then
Else
    Maildb.OPENMAIL
End If

Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = addressee
MailDoc.CopyTo = ccRecipient(0)
MailDoc.subject = subject
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt

For x = 0 To UBound(Attachment) 'loops through each attachment file and adds this to the mail
If Attachment(x) > "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM(Attachment(x))
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment(x), "Attachment")


End If
Next x
MailDoc.CREATERICHTEXTITEM ("Attachment")


MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.ReturnReceipt = RtnRec  'sets the return receipt on or off (0 or 1) value 0 is off.
MailDoc.SEND 0

'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

End Sub
 
Thanks stburkeuk.

That code, with a little fiddling, worked a treat.

One additional question without notice if I may.....

How can I get the text to appear bold in the body of the email?

I've tried a few things, but with zero success. In fact, I have absolutely no idea how this would be done, and to save myself the embarrassment I won't mention my attempts. ;-)

The code for the text in the email currently looks like this -

Rptnum = Me.Report_Number
name = Me.Manager
text2 = Me.Result_of_Incident

text = "Report Number " + Rptnum + " has been edited by " + name
text1 = " and the suggested corrective action approved. This report details a " + text2 + " incident."

'Set up the new mail document[/color green]
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
If Me.General_Manager = "Jane Doe" Then
MailDoc.sendto = address10
End If
If Me.General_Manager = "John Doe" Then
MailDoc.sendto = address9
End If

MailDoc.Subject = "Incident Notification"
MailDoc.body = text + text1
MailDoc.SAVEMESSAGEONSEND = "SaveIt"
[/color blue]

Any help greatly appreciated.

Kev.


This is a politically correct signature, due to constant whinging about my previous signature.
Long live the fun police.
 
Kev,


To be honest - I would love to know!!

I use the same method to send out a realy long mail with Deadlines in it that we would like to highlight in some/any way but have not found a solution to the problem.

If anyone know please let us into the secret.
 
Have you tried this ?
MailDoc.body = "<b>" & text & text1 & "</b>"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
I tried adding the <b> and </b> as per your suggestion, but it only resulted in <b> and </b> being added to the start and end of the body text.

Did I miss something?

Kev.

This is a politically correct signature, due to constant whinging about my previous signature.
Long live the fun police.
 
If the report is an Access report, why not just attach the report to your email. The report will look exactly like it does when you view it in access (bold, color, etc.), providing you output the report in snapshot format.
 
FP,
it's not really a report, just a quick one liner to notify someone that a record has been created.


This is a politically correct signature, due to constant whinging about my previous signature.
Long live the fun police.
 
This is how I structured the body to get bold on.

strBody = "<HTML><HEAD></HEAD><BODY><P> The Print Shop has <b>received</b> an order form </P></BODY></HTML>
 
FP -

I have tried your suggestion but as with above all I am getting is the litteral - "<HTML><HEAD></HEAD><BODY><P> The Print Shop has <b>received</b> an order form </P></BODY></HTML>" in the Mail text.


Is there any settings in Lotus that may need to be changed? or is it the way we are delivering the text as a string?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top