ignazio.pilone was thinking very hard :
È già strano sentirsi usare il pronome di cortesia fuori dal Web,
che sentirselo usare nel Web...
Vorrei lo evitassi, almeno nei miei confronti.
Con una riga di codice si può fare ben poco; con le seguenti
puoi verificare le possibilità di accesso al tuo Outlook:
=========================================
Private Sub Command10_Click()
Dim OL As New outlook.Application, NewMail As MailItem
Dim i As Integer, S As String
Dim AttachmentArray(1 To 3) As String
Dim FSO As Object, TextStream As Object
Dim eMailMessage As String, SendAccount As String
Dim ReceiveAccount As String
'--- Definizioni ----------------------------------
'Testo del messaggio
eMailMessage = "Quando i Romani avevano le palle."
' File contenente il corpo del messaggio
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextStream = FSO.OpenTextFile("D:\Test\aa0.txt")
Do Until TextStream.AtEndOfStream
S = S & vbCrLf & TextStream.ReadLine
Loop
' Tre file costituenti gli attachment
AttachmentArray(1) = "D:\Test\aa1.txt"
AttachmentArray(2) = "D:\Test\aa2.txt"
AttachmentArray(3) = "D:\Test\aa3.txt"
' Indirizzo DAL quale si trasmette
SendAccount = "
xxxxx...@xxxxxx.com"
' Indirizzo AL quale si trasmette
ReceiveAccount = "yyyyy...@yyyyyy.yy"
'----------------------------------------------
On Error GoTo SendErr
Set OL = CreateObject("Outlook.Application")
Set NewMail = OL.CreateItem(olMailItem)
With NewMail
.SendUsingAccount = Session.Accounts(SendAccount)
.To = ReceiveAccount
.CC = "wwwww...@wwwwww.ww; zzzzz...@zzzzzz.zz"
'.BCC = "vvvvv...@vvvvvv.vv; uuuuu...@uuuuuu.uu"
.Subject = "Prova eMail da Access"
.Body = eMailMessage & vbCrLf & S
.ReadReceiptRequested = True ' False
For i = 1 To 3
.Attachments.Add AttachmentArray(i)
Next
.Send
End With
MsgBox "Sent without Errors!"
Exit_Sub:
Exit Sub
SendErr:
MsgBox "Error n. " & Err.Number & vbCrLf & Err.Description
Resume Exit_Sub
End Sub
==================================
Dovrai sostituire i vari xxxxx...@xxxxxx.xx con indirizzi
effettivi e creare i file "D:\Test\aaX.txt" che contengono il
testo e gli allegati, ovvero REMmare le righe di codice che
li riguardano.
In Tools-->References dovrai avere:
- Visual Basic for Applications
- Microsoft Access 16.0 Object Library
- Microsoft Outlook 16.0 Object Library
- Microsoft Office 16.0 Access database engine Object Library
O qualcosa di simile riferito alla versione di Office installata
(forse anche Microsoft Scripting Runtime...)
Inoltre, dovresti creare un file di testo con estensione .REG
contenente:
===============================
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\Security]
"ObjectModelGuard"=dword:00000002
[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security]
"PromptOOMSend"=dword:00000002
"AdminSecurityMode"=dword:00000003
===============================
che dovrai eseguire una tantum per consentire l'accesso ad
Outlook da programma (l'ultima riga - come sopra indicato - deve
risultare blank).
Per quanto riguarda l'intera automazione del laborioso processo,
direi che è fattibile avendo a disposizione uno stralcio
esemplificativo del database sul quale operarre.
Bruno