Solved

Word email VBA error message: "this item has been moved or deleted"

Posted on 2009-05-12
4
802 Views
Last Modified: 2012-05-06
I have a form that I created in Word with an e-mail (SendForReview) button on it. The email works fine, but several minutes after sending, Word opens and an error message pops up that says "this item has been moved or deleted". I click ok, and about a minute later the same thing happens. Then a minute later it happens again.

The code for the button is below, with the email addys removed...

Any ideas?
Private Sub CommandButton1_Click()

    ThisDocument.SendForReview _

        Recipients:="xxxx@xxx.com; xxxx@xxx.org", _

        Subject:="Please review this document.", _

        ShowMessage:=False, _

        IncludeAttachment:=True

End Sub

Open in new window

0
Comment
Question by:statler01
  • 3
4 Comments
 
LVL 13

Assisted Solution

by:game-master
game-master earned 200 total points
ID: 24371927


good afternoon!

try this approach!


sub SendEmail()
    Dim objMsg As Object
    Dim objConfi As Object
    Dim strBody As String
   
    Set objMsg = CreateObject("CDO.Message")
    Set objConfi = CreateObject("CDO.Configuration")
   
    With objMsg
        Set .configuration = objConfi
        .to = <receiver>
        .from = <sender>
        .Subject = "Test"
        .textbody = "This is a test message only."
        .AddAttachment <path of the file to attached>     ' example "C:\test.txt"
        .send
    End With
   
    MsgBox "OK"
end sub


i hope i could give u idea...

game-master
0
 
LVL 13

Assisted Solution

by:game-master
game-master earned 200 total points
ID: 24371934

this approach as well..

Set objSession = CreateObject("MAPI.session")
objSession.Logon profileName:="DARTS"

' Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add

' Set the properties of the message object.
objMessage.Subject = "title"
objMessage.Text = "content"

' Add a recipient object to the objMessage.Recipients collection.
objMessage.Recipients.Add "alberto.viveros@gapac.com"
objMessage.Recipients(1).Type = RECIPTYPE_TO
objMessage.Recipients(1).Resolve

objMessage.Attachments.Add FileName, 0, 1, PathFile
objMessage.Update

objMessage.Send showDialog:=False
objSession.Logoff
0
 
LVL 9

Accepted Solution

by:
statler01 earned 0 total points
ID: 24379253
I found that the problem is that the "SendForReview" method tries to track the email. I had some problems relating to that.

I ended up with the following, which works fine:
Private Sub CommandButton1_Click()

    Dim bStarted As Boolean

    Dim oOutlookApp As Outlook.Application

    Dim oItem As Outlook.MailItem

    On Error Resume Next

        If Len(ActiveDocument.Path) = 0 Then 'Document has not been saved

            ActiveDocument.Save 'so save it

        End If

        'see if Outlook is running and if so turn your attention there

        Set oOutlookApp = GetObject(, "Outlook.Application")

            If Err <> 0 Then 'Outlook isn't running

                'So fire it up

                Set oOutlookApp = CreateObject("Outlook.Application")

                bStarted = True

            End If

        'Open a new e-mail message

        Set oItem = oOutlookApp.CreateItem(olMailItem)

        With oItem 'and add the detail to it

            .To = "abcde@wxyz.org; fghij@wxyz.org" 'send to this address

            .Subject = "Room Reservation" 'This is the message subject

            .Body = "Please review this reservation form." ' This is the message body text

            .Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue

            .Send

        End With

    Me.Close

End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:game-master
ID: 24380628

good morning!

it's good to know that u make it work...


cheers..


game-master
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now