PDA

View Full Version : lotus email problem



ironj32
04-06-2007, 07:40 AM
this is code that it used to submit a questionnaire back to me. can anyone take a look at this code and figure out why this won't return to me. it will work if i send it to myself on my computer. but it is not working from other users lotus email. i am not getting any errors or anything. it acts as if everything was submitted. but the email never shows up to me. i am not sure why it wouldn't work for someone else if it works for me.


'The procedure for executing the main task:
Sub SendWithLotus()
Dim noSession As Object, noDatabase As Object, noDocument As Object
Dim obAttachment As Object, EmbedObject As Object
Dim stSubject As Variant, stAttachment As String
Dim vaRecipient As Variant, vaMsg As Variant

Const EMBED_ATTACHMENT As Long = 1454
Const stTitle As String = "Status Active workbook"
Const stMsg As String = "The active workbook must first be saved before it can be sent as an attachment."
'Check if the active workbook is saved or not
'If the active workbook has not been saved at all.
If Len(ActiveWorkbook.Path) = 0 Then
MsgBox stMsg, vbInformation, stTitle
Exit Sub
End If

'If the changes in the active workbook has been saved or not.


vaRecipient = myemail@myemail.com

'If the user has canceled the operation.
If vaRecipient = False Then Exit Sub
vaMsg = "Here is the completed form."

'Add the subject to the outgoing e-mail which also can be retrieved from the users
'in a similar way as above.
stSubject = "Completed Questionaire: " & Me.txtVendorName

'Retrieve the path and filename of the active workbook.
stAttachment = ThisWorkbook.Path & "\" & Me.txtVendorName & "1.xls"

'Instantiate the Lotus Notes COM's Objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")

'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
Set obAttachment = noDocument.CreateRichTextItem("stAttachment")
Set EmbedObject = obAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.Subject = stSubject
.Body = vaMsg
.SaveMessageOnSend = True
End With
'Send the e-mail.
With noDocument
.PostedDate = Now()
.Send 0, vaRecipient
End With
'Release objects from the memory.
Set EmbedObject = Nothing
Set obAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing

MsgBox "The questionaire has been successfuly submitted.", vbInformation
End Sub

lucas
04-06-2007, 07:45 AM
Is lotus just an email program and this is being run from Excel in this case?

ironj32
04-06-2007, 07:46 AM
that is correct.

lucas
04-06-2007, 08:00 AM
Can't really help you with lotus but here are a couple of links that might help. Steiners uses mapi...might be a solution:
http://vbaexpress.com/kb/getarticle.php?kb_id=311
http://vbaexpress.com/kb/getarticle.php?kb_id=277