Email with Lotus Notes

W

wpshop

I am trying to use the following code but I keep getting an error message
"the expression on click you entered as the event property setting produced
the following error: User defined type not defined". I am new to VBA code.
I found this online and was trying to use it for my purposes.

Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
Dim AttachME As Object
Dim EmbedObj As Object

Set Session = CreateObject("Notes.NotesSession")
Session.Initialize ("password")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1,
UserName, " "))) & ".nsf"
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
MailDoc.SAVEMESSAGEONSEND = SaveIt
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Test")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "H:\Training\Test.doc",
"test")
MailDoc.CREATERICHTEXTITEM ("Test")
End If
MailDoc.PostedDate = Now()
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
 
G

Graham Mandeno

You should compile your project (click on Debug>Compile... in the VBA
window) and that will highlight the exact line which is causing the problem.
Chances are you will figure it out yourself then, but is not, post back with
the extra information.
 
W

wpshop

Okay I figured everything out except my user name is causing me issues. I
need to pull the 4th character instead of the 1st. I'm sure it's easy but I
can't figure it out.
 
W

wpshop

Hi Graham,

Thank you for taking the time to review. I just posted a comment. I think I
got it to work except now I am having issues with my user name. I need to
reference the 4th character and not the 1st.

Graham Mandeno said:
You should compile your project (click on Debug>Compile... in the VBA
window) and that will highlight the exact line which is causing the problem.
Chances are you will figure it out yourself then, but is not, post back with
the extra information.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I am trying to use the following code but I keep getting an error message
"the expression on click you entered as the event property setting
produced
the following error: User defined type not defined". I am new to VBA
code.
I found this online and was trying to use it for my purposes.

Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
Dim AttachME As Object
Dim EmbedObj As Object

Set Session = CreateObject("Notes.NotesSession")
Session.Initialize ("password")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1,
UserName, " "))) & ".nsf"
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
MailDoc.SAVEMESSAGEONSEND = SaveIt
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Test")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "H:\Training\Test.doc",
"test")
MailDoc.CREATERICHTEXTITEM ("Test")
End If
MailDoc.PostedDate = Now()
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
 
W

wpshop

okay I figured out how to pull the fourth character using WordArray and
split. Apparently that's not what I need. I'm not sure what format my
MailDbName is in and my help desk can't help me. If you can think of
anything I'm all ears. Thanks.
 
J

JimT

Try asking your e-mail admin or systems admin. In some organazations the
helpdesk isn't responsible for keeping such lists.

Luck!
-JT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top