Newsgroup: it.comp.appl.access
Titolo: Email automatiche con SendObject

Non sono riuscito a capirci molto nei post che ho trovato in giro...
Uso il comando SendObject per mandare delle mail automatiche (cio� non
vorrei nessun intervento dall'utente in outlook...click o altro...!!!):
DoCmd.SendObject acQuery, "ERR_SOT_0", acFormatXLS, _
                              "
pi...@aaa.it
", , , _
                              "Stato RTU criticit� 0", _
                              "Ciao...."
Mi si apre outlook ma aspetta che qualcuno faccia click sul pulsante
"invia".
Non mi compare la finestra...."un programma esterno sta cercando di
inviare......" come scritto in molti post....
Volevo poter inviare la mail in automatico....ma volevo anche poter
continuare ad utilizzare il comando SendObject perch� mi gestisce bene gli
allegati in versione Excel...
Come posso fare??
Ho letto nei form anche che aggiungendo "false" in fondo al comando
SendObject invia le mail  in automatico(??????????)....(non funziona.....)
Ho anche installato il programmino Express Click Yes.......ma non
funzia......cio� funzionerebbe se uscisse la form "un programma esterno
sta cercando di inviare......" , invece mi esce direttamente la mail dove
devo cliccare su "INVIA"
Grazie per l'aiuto....
Ciao
-- 
questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news
 segnala gli abusi ad 
ab...@newsland.it

 Ciao
Ciao c'è un pò di confusione 
un conto è outlook express uno microsoft outlook, solo quest'ultimo necessita di clickyes
il sendobject invece vuole l'invio dell'utente, ma puoi usare cdo e quindi l'invio sarà trasparente all'utente
Ciao
-- 
-- 
MAssimiliano Amendola
www.accessgroup.it
Cisa - Conferenza Italiana Sviluppatori Access

Memorizza quanto segue in un modulo:
Option Compare Database
Option Explicit
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
'Public Dialogue As MAPIMessage
'Private Dialogue As MAPIMessage
'@@@Outlook Express METTI IL PERCORSO GIUSTO DI MSOE.DLL
Declare Function MAPISendMail Lib "c:\programmi\outlook express\msoe.dll" 
Alias "BMAPISendMail" (ByVal Session&, ByVal UIParam&, Message As 
MAPIMessage, Recipient() As MapiRecip, File() As MapiFile, ByVal flags&, 
ByVal Reserved&) As Long
'@@@Outlook
'Declare Function MAPISendMail Lib "MAPI32.DLL" Alias "BMAPISendMail" (ByVal 
Session&, ByVal UIParam&, Message As MAPIMessage, Recipient() As MapiRecip, 
File() As MapiFile, ByVal flags&, ByVal Reserved&) 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
Global Const MAPI_DIALOG = &H8
Function SendMail(sSubject As String, sTo As String, sCC As String, sCCO As 
String, sAttach As String, sMessage As String, Optional sImmediateSend As 
Boolean = True) As Long
  Dim MAPI_Message As MAPIMessage
  Dim I As Integer
  Dim cTo As Integer
  Dim cCC As Integer
  Dim cCCO As Integer
  Dim cAttach As Integer
  Dim Dialogue As MAPIMessage
  cTo = CountWords(sTo, ";")
  cCC = CountWords(sCC, ";")
  cCCO = CountWords(sCCO, ";")
  cAttach = CountWords(sAttach, ";")
  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
  ParseWords rTo(), sTo, ";"
  ParseWords RCC(), sCC, ";"
  ParseWords rCCO(), sCCO, ";"
  ParseWords rAttach(), sAttach, ";"
  ReDim MAPI_Recip(0 To cTo + cCC + cCCO - 1) As MapiRecip
  For I = 0 To cTo - 1
    MAPI_Recip(I).Name = rTo(I)
    MAPI_Recip(I).RecipClass = MAPI_TO
   Next I
  For I = 0 To cCC - 1
    MAPI_Recip(cTo + I).Name = RCC(I)
    MAPI_Recip(cTo + I).RecipClass = MAPI_CC
  Next I
  For I = 0 To cCCO - 1
    MAPI_Recip(cTo + cCC + I).Name = rCCO(I)
    MAPI_Recip(cTo + cCC + I).RecipClass = MAPI_CCO
  Next I
  ReDim MAPI_File(0 To cAttach) As MapiFile
  MAPI_Message.FileCount = cAttach
  For I = 0 To cAttach - 1
    MAPI_File(I).Position = -1
    MAPI_File(I).PathName = rAttach(I)
  Next I
  MAPI_Message.Subject = sSubject
  MAPI_Message.NoteText = sMessage
  MAPI_Message.RecipCount = cTo + cCC + cCCO
  Dialogue.flags = MAPI_LOGON_UI + MAPI_DIALOG
  'SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), 
Dialogue.flags, 0) '21/02/2007
  SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), 
Dialogue.flags, 0&)
  If SendMail Then MsgBox " Email non creata ", 48, "MODULO MAPI"
  VariabileByte = SendMail 'dichiara la variabile come globale
End Function
Function CountWords(ByVal sSource As String, ByVal sDelim As String) As 
Integer
  Dim iDelimPos As Integer
  Dim iCount As Integer
  If sSource = "" Then
    CountWords = 0
  Else
    iDelimPos = InStr(1, sSource, sDelim)
    Do Until iDelimPos = 0
      iCount = iCount + 1
      iDelimPos = InStr(iDelimPos + 1, sSource, sDelim)
    Loop
    CountWords = iCount + IIf(Right(sSource, 1) = sDelim, 0, 1)
  End If
End Function
Function GetWords(sSource As String, ByVal sDelim As String) As String
  Dim iDelimPos As Integer
  iDelimPos = InStr(1, sSource, sDelim)
  If (iDelimPos = 0) Then
    GetWords = Trim$(sSource)
    sSource = ""
  Else
    GetWords = Trim$(Left$(sSource, iDelimPos - 1))
    sSource = Mid$(sSource, iDelimPos + 1)
  End If
End Function
Sub ParseWords(mArray() As String, ByVal sTokens As String, ByVal sDelim As 
String)
  Dim I As Integer
  For I = LBound(mArray) To UBound(mArray)
    mArray(I) = GetWords(sTokens, sDelim)
  Next I
End Sub
Fine Modulo
Sub:
  Dim EMail As String, CartellaPredefinitaPdf As String
  Dim aFiles As String, MSGX As String, OBJX As String
 SendMail OBJX, EMail, "", "", aFiles, MSGX, 0
Fine Sub
Ciao
Graziano