build an email message and save it into the Draf folder

R

rocco

Hello,
I have wrote code in Access to create an email message with an attachment (
a .zip file choosen from user through a FileDialogPicker.
I would like to save the messa into the Draft folder...now..it seems I'm
having trouble with the save method. Debugging says it is all right...but the
save method shows in *lowercase* (i.e. mssg.save instead of mssg.Save) ...
which sounds like an alert that something is going wrong. If I use the SaveAs
method, instead, it shows in the *first letter capitalized* fashion...so
what's wrong with the save method? I'm on this thing from this morning and I
really canno tfigured out what' wrong. If run the procedure it goes all the
way down without any error...but the message is not saved.
Here is my code:

On Error GoTo email_err

Dim objol As Object
On Error Resume Next
Set objol = GetObject("Outlook.application")
Dim msgg As Object
Dim vrtSelectedItem As Variant
With objol
Set msgg = .CreateItem(olMailItem)
End With

With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
..Title = "Selezionare il file di back up da inviare"
..InitialFileName = CurrentProject.Path & "\ArchivioDati\"
..Filters.Clear
..ButtonName = "Seleziona"
..Filters.ADD "zipped files", "*.zip"

If .show=-1 then
For Each vrtSelectedItem In .SelectedItems
msgg.Attachments.ADD vrtSelectedItem
Next vrtSelectedItem
msgg.To = InputBox("Indicare l'indirizzo di posta elettronica a cui
inviare il messaggio: ", "Indirizzo em@il del destinatario")
msgg.Subject = "Invio delle tabelle del database da: " &
CurrentUser() & "; il: " & Now()
msgg.save
Dim myNameSpace As Outlook.NameSpace
Dim myDraft As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Set myNameSpace = objol.GetNamespace("MAPI")
Set myDestFolder = myNameSpace.Folders(olFolderDrafts)
msgg.Move myDestFolder

Set myNameSpace = Nothing
Set myDestFolder = Nothing
Else
Set objol = Nothing
Set msgg = Nothing
Exit Sub
End If
End With

Exit Sub

email_err:
If Err.Number = 429 Then
Set objol = CreateObject("Outlook.application")
Resume Next
Else
MsgBox "La procedura ha riscontrato un errore. Controllare che:" + vbCrLf + _
"a) sia stata fatta l'esportazione delle tabelle" + vbCrLf + _
"b) siano state zippate in un unico file .zip le tabelle esportate" + vbCrLf
+ _
"c) Microsoft Outlook sia installato e configurato sul proprio sistema.",
vbCritical, "Errore nella procedura!"
Set objol = Nothing
Exit Sub
End If

Thanks!
Rocco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top