VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a

by David Koopman (11 Submissions)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 12th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a recent project and it works great. Accepts

Rate This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a



To check for pass fail I am returning a Long. Either a 1 for pass or a 0 for failure so the End User knows whether the Send was successful or not. Could also return Boolean(True/False). Below is the front end code to describe how I referenced the function and passed the parameters. Enjoy

Create a Project Named Mail
Add a Class Module Named CMail and paste function below.
Add a form with a Command button and 5 text boxes and paste the code on the bottom.

Public Function SendMail(ByVal strTo As String, _
                       ByVal strFrom As String, _
                       ByVal strCC As String, _
                       ByVal strSubject As String, _
                       ByVal strBody As String) As Long
                                                            
'Basic Error Handling
On Error GoTo EmailError

    Dim s As Object
    Dim db As Object
    Dim doc As Object
        
's and db declared in general as object
Set s = CreateObject("Notes.Notessession")  'create session
Set db = s.GetDatabase("", "")   'not yet named
Call db.OPENMAIL    'set database to default 
Set doc = db.CreateDocument  ' create a mail document
'Use parameters to build Email message
Call doc.ReplaceItemValue("SendTo", strTo)
Call doc.ReplaceItemValue("From", strFrom)
Call doc.ReplaceItemValue("CopyTo", strCC)
Call doc.ReplaceItemValue("Subject", strSubject)
Call doc.ReplaceItemValue("Body", strBody)
     doc.SaveMessageOnSend = True      'Save in Sent Folder
Call doc.Send(False)                   'send message
Set s = Nothing                        'Kill objects to free memory
Set db = Nothing
Set doc = Nothing

EmailExit:
  'Success
  SendMail = 1
  Exit Function
  
EmailError:
'Failed
SendMail = 0
   App.StartLogging App.Path & "\CMAC_Email.log", vbLogToFile
   App.LogEvent Now & Err.Description, vbLogEventTypeError
Resume EmailExit

End Function

'=============================================================================
'=============================================================================

'On Form

Private Sub cmdSend_Click

Dim oEmail as New Mail.CMail
Dim lngReturn as Long

lngReturn = oEmail.SendMail(text1.Text, _
                          text2.Text, _
                          text3.Text, _
                          text4.Text, _
                          text5.Text)
                      
If lngReturn = 1 Then   'Email successful
    MsgBox "Fund updated and completed!" & vbCrLf & _
    "Check Lotus for successful delivery!", vbOKOnly+vbSystemModal, & _
    "Updated and Completed"
   Exit Sub
Else 'Email failed
   MsgBox "Failed" & vbCrLf & Err.Description, vbOKOnly, "Failure occurred!"
   Exit Sub
End If

End Sub

Download this snippet    Add to My Saved Code

This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a Comments

No comments have been posted about This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a. Why not be the first to post a comment about This code will send Email using Lotus Notes and save a copy to your Sent folder. I wrote this for a.

Post your comment

Subject:
Message:
0/1000 characters