If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > SendMail and Lotus Notes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-10, 18:34
Bob.Carter.17 Bob.Carter.17 is offline
Registered User
 
Join Date: Dec 2005
Posts: 111
SendMail and Lotus Notes

All,
I have always used the Macro SendObject, form, HTML format, then set the to, subject and message in the macro.

I understand there is ways to do this using code so you don't have to go to the Notes client and click send with each email. However I am not quite understanding what needs to be done. I have found code such as below on some sites that say it will work, like -

Option Explicit

Private Sub SendEmailLotus()
Dim s As Object
Dim db As Object
Dim doc As Object
Dim sMsg As String

Set s = CreateObject("Notes.Notessession") 'Create notes session
Set db = s.getdatabase("", "") 'Set db to database not yet named
Call db.openmail 'Set database to default mail database
Set doc = db.createdocument 'Notesdocument '.New '(db) ' create a mail document
sMsg = "Mail has been sent: " & Date & " " & Time() & Chr$(10) & _
"This is a test of an email message from VB." & vbCrLf & Text1.Text '
Call doc.replaceitemvalue("SendTo", "Eric Burdo") '
Call doc.replaceitemvalue("Subject", "VB message") '
Call doc.replaceitemvalue("Body", sMsg) '
Call doc.Send(False) 'Send the message
MsgBox doc.getitemvalue("Body")(0) '
Set s = Nothing 'Close connection to free memory
Set db = Nothing 'Cleanup
Set doc = Nothing 'Cleanup
End Sub

However I am not quite sure how to set this up to email the information off of a form that opens in an email, and what variables I need to change in this code to make it work for my situation. The form has about 5 or 6 fields that need to be shown on the email (always liked the HTML format) when it opens. I can trigger the open when needed (when the condition to send the information via email is met).

Any help on this from someone who has past experience in making this work? I would like to have this just send behind the scenes.

Thanks for everyone's help both now and in the past!
Reply With Quote
  #2 (permalink)  
Old 01-28-10, 23:06
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
As far as using fields on a form, there are some email examples in the code bank but they use the sendobject command for outlook.

As far as the code to create or send the email for lotus, you'd probably need to google for code to do that. I googled for Groupwise code to use in vba and it worked great.

(or hope someone else has the code and posts it here as a response.)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #3 (permalink)  
Old 01-28-10, 23:12
canupus canupus is offline
Registered User
 
Join Date: Jul 2004
Location: South Dakota
Posts: 242
I have some code at the office to send email using CDO. I can post it tomorrow. Think it will have what you are looking for.

C
Reply With Quote
  #4 (permalink)  
Old 02-02-10, 20:34
canupus canupus is offline
Registered User
 
Join Date: Jul 2004
Location: South Dakota
Posts: 242
Here is the code that I use to send emails without using Outlook or another email client.

Code:
Public Function SendEmail(pFrom As String, pTo As String, pSubj As String, _
    Optional pBody As String, Optional pAttach As String) As Boolean
    
    On Error GoTo ErrHandler

    Dim objMessage As Object

    Set objMessage = CreateObject("CDO.Message")
    objMessage.From = pFrom
    objMessage.To = pTo
    objMessage.Subject = pSubj
    objMessage.HTMLBody = pBody
    
    If pAttach <> "" Then objMessage.AddAttachment pAttach
     
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = EnterYourServerHere
    
    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    
    objMessage.Configuration.Fields.Update

    objMessage.Send
    
    'if made it here then email was sent
    SendEmail = True
    
ExitHere:
    Set objMessage = Nothing
    Exit Function
    
ErrHandler:
    SendEmail = False
    Resume ExitHere
End Function
I just create an HTML formatted string for the body and pass that to the function. It does use Microsoft CDO.

Hope it helps.

C
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On