Newsgroup: it.comp.appl.access
Titolo: invio allegati email

Uso il seguente codice per inviare da access email con allegati.Il problema
e che la email viene inviata senza che l'utente possa aprirla primadi
inviarla per le eventuali modifiche. Qualcuno sa se e dove è possivile
modificare questo codice affinche prima di essere inviata l'email venga
visualizzata ?
Option Explicit
Option Compare Database 'Use database order for string comparisons
'Declare Special Types for use with MAPI
Type MAPIMessage
   Reserved As Long
   Subject As String
   NoteText As String
   MessageType As String
   DateReceived As String
   ConversationID As String
   flags As Long
   RecipCount As Long
   FileCount As Long
End Type
Type MapiRecip
   Reserved As Long
   RecipClass As Long
   Name As String
   Address As String
   EIDSize As Long
   EntryID As String
End Type
Type MapiFile
   Reserved As Long
   flags As Long
   Position As Long
   PathName As String
   FileName As String
   FileType As String
End Type
'DLL Functions in MAPI module
'MsOutlook : Change "C:\programmi\Outlook Express\Msoe.dll" in "Mapi32.dll"
 Declare Function MAPISendMail Lib "C:\programmi\Outlook Express\Msoe.dll" _
    Alias "BMAPISendMail" ( _
    ByVal Session As Long, _
    ByVal UIParam As Long, _
    Message As MAPIMessage, _
    Recipient() As MapiRecip, _
    File() As MapiFile, _
    ByVal flags As Long, _
    ByVal Reserved As Long) As Long
Global Const SUCCESS_SUCCESS = 0
Global Const MAPI_TO = 1
Global Const MAPI_CC = 2
Global Const MAPI_CCO = 3
Global Const MAPI_LOGON_UI = &H1
'*************************************************************
' FUNCTION NAME: CountTokens
'
' PURPOSE:
' Given a string of delimited items and the delimiter, the number
' of tokens in the string will be returned. This function is useful
' for dimensioning an array to store the delimited items prior to
' calling ParseTokens.
'
' INPUT PARAMETERS:
' sSource: A delimited list of tokens
' sDelim: The delimiter used to delimit sSource
'
' RETURN
' The number of tokens in sSource, which is the number of delimiters
' plus 1. If sSource is empty, 0 is returned.
   '*************************************************************
   Function CountTokens(ByVal sSource As String, ByVal sDelim As String)
    Dim iDelimPos As Integer
    Dim iCount As Integer
' Number of tokens = 0 if the source string is empty
    If sSource = "" Then
        CountTokens = 0
' Otherwise number of tokens = number of delimiters + 1
    Else
        iDelimPos = InStr(1, sSource, sDelim)
        Do Until iDelimPos = 0
            iCount = iCount + 1
            iDelimPos = InStr(iDelimPos + 1, sSource, sDelim)
        Loop
        CountTokens = iCount + IIf(right(sSource, 1) = sDelim, 0, 1)
    End If
End Function
'*************************************************************
' FUNCTION NAME: GetToken
'
' PURPOSE:
' Given a string of delimited items, the first item will be
' removed from the list and returned.
'
' INPUT PARAMETERS:
' sSource: A delimited list of tokens
' sDelim: The delimiter used to delimit sSource
'
' RETURN
' sSource will have the first token removed. The function
' returns the token removed from sSource.
'*************************************************************
Function GetToken(sSource As String, ByVal sDelim As String) As String
    Dim iDelimPos As Integer
' Find the first delimiter
    iDelimPos = InStr(1, sSource, sDelim)
' If no delimiter was found, return the existing string and set
' .. the source to an empty string.
    If (iDelimPos = 0) Then
        GetToken = trim$(sSource)
        sSource = ""
' Otherwise, return everything to the left of the delimiter and
' .. return the source string with it removed.
    Else
        GetToken = trim$(left$(sSource, iDelimPos - 1))
        sSource = Mid$(sSource, iDelimPos + 1)
    End If
End Function
'*************************************************************
' SUB NAME: ParseTokens
'
' PURPOSE:
' Extracts information from a delimited list of items and places
' it in an array.
'
' INPUT PARAMETERS:
' mArray(): A one-dimensional array of strings in which the parsed
' tokens will be place
' sTokens: A delimited list of tokens
' sDelim: The delimiter used to delimit sTokens
'
' RETURN
' None
'*************************************************************
Sub ParseTokens(mArray() As String, ByVal sTokens As String, ByVal sDelim As
String)
   Dim i As Integer
   For i = LBound(mArray) To UBound(mArray)
      mArray(i) = GetToken(sTokens, sDelim)
   Next
End Sub
'*************************************************************
' FUNCTION NAME: SendMail
'
' NOTE: This was "borrowed" from the Microsoft SDN
'
' PURPOSE:
' This is the front-end function to the MAPISendMail function. You
' pass a semicolon-delimited list of To and CC recipients, a
' subject, a message, and a delimited list of file attachments.
' This function prepares MapiRecip and MapiFile structures with the
' data parsed from the information provided using the ParseRecord
' sub. Once the structures are prepared, the MAPISendMail function
' is called to send the message.
'
' INPUT PARAMETERS:
' sSubject: The text to appear in the subject line of the message
' sTo: Semicolon-delimited list of names to receive the
' message
' sCC: Semicolon-delimited list of names to be CC'd
' sCCO: Semicolon-delimited list of names to be CCO'd
' sAttach: Semicolon-delimited list of files to attach to
' the message
' RETURN
' SUCCESS_SUCCESS if successful, or a MAPI error if not.
'*************************************************************
Function SendMail(sSubject As String, sTo As String, sCC As String, _
sCCO As String, sAttach As String, sMessage As String) As Long
   Dim i, cTo, cCC, cCCO, cAttach ' variables holding counts
   Dim MAPI_Message As MAPIMessage
   ' Count the number of items in each piece of the mail message
   cTo = CountTokens(sTo, ";")
   cCC = CountTokens(sCC, ";")
   cCCO = CountTokens(sCCO, ";")
   cAttach = CountTokens(sAttach, ";")
   ' Create arrays to store the semicolon delimited mailing
   ' .. information after it is parsed
   ReDim rTo(0 To cTo) As String
   ReDim rCC(0 To cCC) As String
   ReDim rCCO(0 To cCCO) As String
   ReDim rAttach(0 To cAttach) As String
   ' Parse the semicolon delimited information into the arrays.
   ParseTokens rTo(), sTo, ";"
   ParseTokens rCC(), sCC, ";"
   ParseTokens rCCO(), sCCO, ";"
   ParseTokens rAttach(), sAttach, ";"
   ' Create the MAPI Recip structure to store all the To and CC
   ' .. information to be passed to the MAPISendMail function
   ReDim MAPI_Recip(0 To cTo + cCC + cCCO - 1) As MapiRecip
   ' Setup the "TO:" recipient structures
   For i = 0 To cTo - 1
      MAPI_Recip(i).Name = rTo(i)
      MAPI_Recip(i).RecipClass = MAPI_TO
   Next i
   ' Setup the "CC:" recipient structures
   For i = 0 To cCC - 1
      MAPI_Recip(cTo + i).Name = rCC(i)
      MAPI_Recip(cTo + i).RecipClass = MAPI_CC
   Next i
   ' Setup the "CCO:" recipient structures
   For i = 0 To cCCO - 1
      MAPI_Recip(cTo + cCC + i).Name = rCCO(i)
      MAPI_Recip(cTo + cCC + i).RecipClass = MAPI_CCO
   Next i
   ' Create the MAPI File structure to store all the file attachment
   ' .. information to be passed to the MAPISendMail function
   ReDim MAPI_File(0 To cAttach) As MapiFile
   ' Setup the file attachment structures
   MAPI_Message.FileCount = cAttach
   For i = 0 To cAttach - 1
      MAPI_File(i).Position = -1
      MAPI_File(i).PathName = rAttach(i)
   Next i
   ' Set the mail message fields
   MAPI_Message.Subject = sSubject
   MAPI_Message.NoteText = sMessage
   MAPI_Message.RecipCount = cTo + cCC + cCCO
   ' Send the mail message
   SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(),
MAPI_LOGON_UI, 0&)
End Function
Private Sub Comando60_Click()
 
 SendMail "oggetto", "
t...@test.fr
", "
t...@test.fr
", "
t...@test.fr
",
"c:/pipp.pdf;c:/pluto.pdf", "messaggio "
 
End Sub
--------------------------------
Inviato via 
http://arianna.libero.it/usenet/

 ha scritto nel messaggio 
news:151Z38Z87Z141Y1...@usenet.libero.it...
