Error message when saving a message

  • Thread starter Thread starter HomeroOM
  • Start date Start date
H

HomeroOM

I've created a simple piece of VBA code, intending to save a message
programmtically created.

The code follows:
----------------
Dim A As Application
Dim M As MailItem
Dim R As Recipient

Set A = Application

Set M = A.CreateItem(olMailItem)

M.Body = "this is a single message testing."

Set R = M.Recipients.Add("(e-mail address removed)")

R.Type = olOriginator

M.Subject = "Mensagens para arquivar"

Set R = M.Recipients.Add("(e-mail address removed)")

R.Type = olTo

M.Save

Set A = Nothing
Set M = Nothing
Set R = Nothing
 
That is strange - it works fine for me. What version of Outlook?

The only thing I can think of doing is to fully qualify your variables when
you declare them (i.e. Dim A As Outlook.Application). Also try M.Display and
don't call save, and see if you can send or save it manually.
 
Dear Eric

I've tried and it didn't work.

The message occurs, though, after the yes answer to a message box asking me
to save the message.

The A.Display worked OK.

The code I've posted is very simple and so is my intent.

Some things, for simplicity puposes only, I've ommited:

1. I invoke the code through an optin button in a User Form.
The code is:
-----------
Private Sub optEviaMsgAnexadas_Click()

modUtilitários.PrepararRemessaDeMensagens

End Sub
-----------
2. Although Outlook is installed in my PC, the PC is connected to a
microsoft network.

The macro I've used to show the form is:
----------
Public Sub PrepararEmails()

frmPreparaMensagens.Show vbModeless

End Sub
----------

The vbModeless constant was necessary because the display worked on my
debbuging session (inside VBA IDE) and issued the same message that Save is
issuing when I was invoking from a buttom on my Outlook toolbar.

Thanks for your super fast answer.

Keep up the good work

Homero
 
Back
Top