Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 25th, 2005, 02:53 AM
saabman saabman is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 68 saabman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 34 m 21 sec
Reputation Power: 5
Question How to save e-mail in the "sent" box using Lotus Notes

Hi all!
I am posting rather often here as I am on a big project! I have a slight problem with an automation I have set up. I have a function that allows me to send an automatic e-mail using Lotus Notes. But the problem I have is that I cant get it to save the message in the "sent items folder". I would be very greatful for some help

Here is the code I use:
Code:
Option Compare Database

'------------------------------------------------------------------------
' This code is used to send an automated e-mail from an access database.
' Thanx to - oharab - for helping with the code ;-)
'------------------------------------------------------------------------

Option Explicit

Private Declare Function apiFindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal strClass As String, _
    ByVal lpWindow As String) As Long

Private Declare Function apiSendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal _
    wParam As Long, lParam As Long) As Long
    
Private Declare Function apiSetForegroundWindow Lib "user32" Alias _
    "SetForegroundWindow" (ByVal hwnd As Long) As Long
    
Private Declare Function apiShowWindow Lib "user32" Alias _
    "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    
Private Declare Function apiIsIconic Lib "user32" Alias _
    "IsIconic" (ByVal hwnd As Long) As Long
    
Function SendNotesMail(strTo As String, strSubject As String, strBody As String, strFilename As String, ParamArray strFiles())

'-----------------------------------------------------------------------------------------
' The Function "SendNotesMail" is used to send the e-mail with the desired attachment(s).
'-----------------------------------------------------------------------------------------

    Dim doc As Object   'Lotus NOtes Document
    Dim rtitem As Object
    Dim Body2 As Object
    Dim ws As Object    'Lotus Notes Workspace
    Dim oSess As Object 'Lotus Notes Session
    Dim oDB As Object   'Lotus Notes Database
    Dim X As Integer    'Counter
    'use on error resume next so that the user never will get an error
    'only the dialog "You have new mail" Lotus Notes can stop this macro
    
If fIsAppRunning = False Then
    MsgBox "Lotus Notes is not running" & Chr$(10) & "Make sure Lotus Notes is running and you have logged on."
    Exit Function
End If

On Error Resume Next
    
'access the logged on users mailbox.
    Set oSess = CreateObject("Notes.NotesSession")
    Set oDB = oSess.GetDatabase("", "")
    Call oDB.OPENMAIL

'create a new document as add text.
    Set doc = oDB.CreateDocument
    Set rtitem = doc.CreateRichTextItem("Body")
    doc.SendTo = strTo
    doc.subject = strSubject
    doc.Body = strBody & vbCrLf & vbCrLf

'attach files.
    If strFilename <> "" Then
        Set Body2 = rtitem.EmbedObject(1454, "", strFilename)
        If UBound(strFiles) > -1 Then
            For X = 0 To UBound(strFiles)
                Set Body2 = rtitem.EmbedObject(1454, "", strFiles(X))
            Next X
        End If
    End If
    doc.Send False
    
End Function


Private Function fIsAppRunning() As Boolean

'--------------------------------------
'Looks to see if Lotus Notes is open.
'Code adapted from code by Dev Ashish.
'--------------------------------------

    Dim lngH As Long
    Dim lngX As Long, lngTmp As Long
    Const WM_USER = 1024
    On Local Error GoTo fIsAppRunning_Err
    fIsAppRunning = False
        
        lngH = apiFindWindow("NOTES", vbNullString)

    If lngH <> 0 Then
        apiSendMessage lngH, WM_USER + 18, 0, 0
        lngX = apiIsIconic(lngH)
        If lngX <> 0 Then
            lngTmp = apiShowWindow(lngH, 1)
        End If
        fIsAppRunning = True
    End If
fIsAppRunning_Exit:
    Exit Function
fIsAppRunning_Err:
    fIsAppRunning = False
    Resume fIsAppRunning_Exit
End Function


Many thanx

Reply With Quote
  #2  
Old August 26th, 2005, 12:26 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
My guess is you'll have to find the answer in Notes, not in your VB code.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > How to save e-mail in the "sent" box using Lotus Notes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT