attaching files to email

presuming_ed

Registered User.
Local time
Today, 03:58
Joined
May 6, 2003
Messages
23
I'm running the following code to send an email via Lotus notes. I'm specifying which email account to send it from which works fine. The problem I've got is when I'm attempting to attach a file to the mail I get the message 'Run time error 438. Object doesn't support this property or method. Any ideas? This is the code I'm running.... The problem is on the Set ATTACHME line.

Thanks.

'Set up the objects required for Automation into lotus notes
Dim Subject As String
Dim Attachment As String
Dim recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
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)
Dim EmailSend As Object
Dim EmailApp As Object

'Start a session to notes
'Set Session = CreateObject("Notes.NotesSession")
Set Session = CreateObject("notes.notesUIWORKSPACE")

'Get the sessions username and then calculate the mail file name.
'You may or may not need this as for MailDBname with some systems you can pass an empty string
MailDbName = "mail\srscallc.nsf"


'Set up the new mail document
Set Maildb = Session.COMPOSEDOCUMENT("cardiff_damal01/SRV/UK/TESCO", MailDbName, "Memo")
Maildb.FIELDSETTEXT "Subject", strSubject
Maildb.FIELDSETTEXT "Body", strBody
Maildb.FIELDSETTEXT "SendTo", strSendTo

'Set up the embedded object and attachment and attach it

Set AttachME = Maildb.CreateRichTextItem("C:\stock_tracker.xls")
Set EmbedObj = AttachME.EmbedObject(1454, "", "C:\stock_tracker.xls")

'Send the document
'MailDoc.Send 0, recipient
Maildb.Send
Maildb.Close
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
 
I probably send out 2-3 thousand emails a day with attachments from Lotus Notes. Here is the code I use.

Set objRichTextAttach = objDoc.CREATERICHTEXTITEM("File")

Set objAttachment = objRichTextAttach.EMBEDOBJECT(1454, "", strFile)
 
Forgive me if I'm being a bit dim, but isn't that the code that I'm running? My problem is that I'm sending the mail from a mail account other than the default, and am using the COMPOSEDOCUMENT method. The code to attach the file does not work in this case.
 
It's pretty close, but not quite the same. I believe that you need to change your line "Set AttachME = Maildb.CreateRichTextItem("C:\stock_tracker.xls")". Replace the "C:\..." with "File". In Lotus you need to create the text item of a "file" and then fill the item with the file (name and path) you are trying to attach. In your case you are trying to create the "C:\.." item which Lotus does not understand.

Post back what you get...
 
Chenn,

Thanks for the reply. I wonder if you can elaborate as I'm totally new to Lotus script. How exactly do I create the text item of a "file" in Lotus and then fill the item with the file I'm trying to attach.

Cheers.
 
Replace your line:

Set AttachME = Maildb.CreateRichTextItem("C:\stock_tracker.xls")

With:

'create the file item
Set AttachME = Maildb.CreateRichTextItem("File")

The next line in your code fills the item with the file:

'fill the file item with the file
Set EmbedObj = AttachME.EmbedObject(1454, "", "C:\stock_tracker.xls")
 
I've tried this but am still getting the message ' run time error 438. object doesn't support this property or method' Additionally the email it creates is from the default author, and not the one defined as MailDb.
 
What line is it failing on? Step through the code to find it.
 
It's failing on the following line:

Set AttachME = Maildb.CreateRichTextItem("file")

I'm just wondering whether it's anything to do with sending from an email account other than my default, as my original code to attach the file and send it worked.
 
Isn't it really annoying when someone starts helping you.... and once they reach a point where they can't help anymore, instead of saying so they just lead you up the garden path!
 
Dont knock it he is only trying to help you IN HIS OWN TIME. Not getting paid or anything. How "annoying" is it to get free help? Wait ! patiently... if you get any reply after this...

Regards
 

Users who are viewing this thread

Back
Top Bottom