kahvedzic
asked on
Error when sending lotus notes mail from vb5 application (MAPI controls)
When I try to send LN mail from Visual Basic 5 application I get an error message
Run-time error '7225'
File not found (notice double space here)
After click on debug I get that error is in this line of code:
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment" & Format(i, "#"))
This line is part of this code:
This application is from VB 5 and data for lotus notes mail is loaded from sql server to VB form.
Any idea why is this happening and how to solve this problem so I can send mails without this message.
Thanks.
Run-time error '7225'
File not found (notice double space here)
After click on debug I get that error is in this line of code:
Set EmbedObj = AttachME.EMBEDOBJECT(1454,
This line is part of this code:
This application is from VB 5 and data for lotus notes mail is loaded from sql server to VB form.
Any idea why is this happening and how to solve this problem so I can send mails without this message.
Thanks.
Public Sub SendNotesMail(Subject As String, AttachmentG As String, Number As Integer, Recipient As String, BodyText As String, SaveIt As Boolean)
Dim Maildb As Object ' mail database
Dim UserName As String 'LN username
Dim MailDbName As String 'notes mail database name
Dim MailDoc As Object 'mail document
Dim AttachME As Object 'attachment object
Dim Session As Object 'notes session
Dim EmbedObj As Object 'Attachment
'Dim Recip(2) As Variant
'SendTo1 = Trim(TextSendTo1)
Recipient = SendTo
'Recip(1) = SendTo1
Set Session = CreateObject("Notes.NotesSession")
'Session.Initialize ("passw")
UserName = Session.UserName
MailDbName = GbazaNSF
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Notes vec otvoren !!!
Else
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.CopyTo = cc
MailDoc.BlindCopyTo = bcc
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
poz = 1
poz1 = 1
For i = 1 To Number
poz2 = InStr(poz1, AttachmentG, ",")
If poz2 = 0 Then
poz2 = Len(AttachmentG) + 1
End If
Attachment = Mid(AttachmentG, poz1, poz2 - poz1)
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment" & Format(i, "#"))
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment" & Format(i, "#"))
'MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
poz1 = poz2 + 1
Next i
MailDoc.PostedDate = Now()
MailDoc.Send 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
sorry just read the code a little closer try this:
...
Attachment = Mid(AttachmentG, poz1, poz2 - poz1)
Attachment = Attachment & Format(i, "#")
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM ("Attachme nt")
...
NG,
...
Attachment = Mid(AttachmentG, poz1, poz2 - poz1)
Attachment = Attachment & Format(i, "#")
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM
...
NG,
I think you're going the wrong way now.
The memo should have a field of type richtext, called "body".
You could attach a file inside this body field.
In your original code, MailDoc.Body = BodyText would create a body field populated with whatever text you supplied, but the field would be (normal) text. Normal text fields do not support attachments.
Without knowing too much of VB, the following could help you out:
Set AttachME = MailDoc.CREATERICHTEXTITEM ("BODY")
AttachME.AppendText(BodyTe xt)
AttachME.AddNewLine(1)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment" & Format(i, "#"))
The memo should have a field of type richtext, called "body".
You could attach a file inside this body field.
In your original code, MailDoc.Body = BodyText would create a body field populated with whatever text you supplied, but the field would be (normal) text. Normal text fields do not support attachments.
Without knowing too much of VB, the following could help you out:
Set AttachME = MailDoc.CREATERICHTEXTITEM
AttachME.AppendText(BodyTe
AttachME.AddNewLine(1)
Set EmbedObj = AttachME.EMBEDOBJECT(1454,
What exactly is the value of Attachment when you use it in .EMBEDOBJECT?
Would that explain the double space in the error message?
You need a valid path to the file that you want to attach there!
Would that explain the double space in the error message?
You need a valid path to the file that you want to attach there!
ASKER
I have just tried and when I send LN mail without attachment get an error File not found, but when I add an attachment mail is sent. If I comment line where debug shows error mail is sent but without any attachment. I guess what I need to do is to set attachME as "" if there is no attachment, but question is how to do that.
I think you just need to add the file..
If Attachment <> "" Then
Call Body.EMBEDOBJECT(1454, "", Attachment, "Attachment")
End If
Also, take a look at this thread from IBM:
http://www-01.ibm.com/support/docview.wss?uid=swg21178583
NG,
If Attachment <> "" Then
Call Body.EMBEDOBJECT(1454, "", Attachment, "Attachment")
End If
Also, take a look at this thread from IBM:
http://www-01.ibm.com/support/docview.wss?uid=swg21178583
NG,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set AttachME = MailDoc.CREATERICHTEXTITEM
S/B something like
Attachment= "C:\ActiveSheet.xls"
Set AttachME = MailDoc.CREATERICHTEXTITEM
Since there is no reference to a file to attach?
NG,