help - using VB to send mail to Lotus Notes 
Author Message
 help - using VB to send mail to Lotus Notes

hi, I'm trying to send mail to lotus notes using VBA I got
some code off the internet (see below) but I get an error,
I think that maybe I need to set a reference, any ideas ??
The line I get an error on is ...

Set Session = CreateObject("Notes.NotesSession") The error
is
Runtime error 429
ActiveX object can't create a component

thanks in advance for any help !

*****************************************************

Public Sub SendNotesMail(Subject As String, Attachment As
String, Recipient As String, BodyText As String, SaveIt As
Boolean)

'Set up the objects required for Automation into lotus notes

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)

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

'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
UserName = Session.UserName

MailDbName = Left$(UserName, 1) & Right$(UserName, (Len
(UserName) - InStr(1, UserName, " "))) & ".nsf"

'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
 'Already open for mail
Else
 Maildb.OPENMAIL
End If

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT

MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt

'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
 Set AttachME = MailDoc.CREATERICHTEXTITEM ("Attachment")
 Set EmbedObj = AttachME.EMBEDOBJECT
(1454, "",Attachment, "Attachment")
 MailDoc.CREATERICHTEXTITEM ("Attachment")
End If

'Send the document
MailDoc.SEND 0, Recipient

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

* Sent from AltaVista http://www.*-*-*.com/ Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful



Wed, 18 Jun 1902 08:00:00 GMT  
 help - using VB to send mail to Lotus Notes
You must have the Notes client install on the machine that your vb
program executes on....
Quote:

> hi, I'm trying to send mail to lotus notes using VBA I got
> some code off the internet (see below) but I get an error,
> I think that maybe I need to set a reference, any ideas ??
> The line I get an error on is ...

> Set Session = CreateObject("Notes.NotesSession") The error
> is
> Runtime error 429
> ActiveX object can't create a component

> thanks in advance for any help !

> *****************************************************

> Public Sub SendNotesMail(Subject As String, Attachment As
> String, Recipient As String, BodyText As String, SaveIt As
> Boolean)

> 'Set up the objects required for Automation into lotus notes

> 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)

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

> '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
> UserName = Session.UserName

> MailDbName = Left$(UserName, 1) & Right$(UserName, (Len
> (UserName) - InStr(1, UserName, " "))) & ".nsf"

> 'Open the mail database in notes
> Set Maildb = Session.GETDATABASE("", MailDbName)
> If Maildb.ISOPEN = True Then
>  'Already open for mail
> Else
>  Maildb.OPENMAIL
> End If

> 'Set up the new mail document
> Set MailDoc = Maildb.CREATEDOCUMENT

> MailDoc.Form = "Memo"
> MailDoc.sendto = Recipient
> MailDoc.Subject = Subject
> MailDoc.Body = BodyText
> MailDoc.SAVEMESSAGEONSEND = SaveIt

> 'Set up the embedded object and attachment and attach it
> If Attachment <> "" Then
>  Set AttachME = MailDoc.CREATERICHTEXTITEM ("Attachment")
>  Set EmbedObj = AttachME.EMBEDOBJECT
> (1454, "",Attachment, "Attachment")
>  MailDoc.CREATERICHTEXTITEM ("Attachment")
> End If

> 'Send the document
> MailDoc.SEND 0, Recipient

> 'Clean Up
> Set Maildb = Nothing
> Set MailDoc = Nothing
> Set AttachME = Nothing
> Set Session = Nothing
> Set EmbedObj = Nothing End Sub

> * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sending e-mails with MAPI from VB5 on system using Lotus Notes

2. send a mail with vb via lotus notes

3. ****Lotus Notes*** sending mail from VB

4. Sending a Lotus Note Mail through VB Program

5. Sending a Lotus Notes-Mail from VB

6. Help - Creating a Lotus Notes Document in a local Lotus Notes DB with VB6

7. VBA code to send an email message through Lotus Notes mail interface

8. How to send a Lotus Notes e-mail from Access

9. sending a e-mail from excel via Lotus Notes

10. How to Send Mail From VB5.0 to Lotus Notes

11. Sending attachment through Lotus Notes using SendObject

12. Send Message Using Lotus Notes (MAPI compliant?)

 

 
Powered by phpBB® Forum Software