?
Solved

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

Posted on 2009-05-12
4
Medium Priority
?
818 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 13

Assisted Solution

by:game-master
game-master earned 800 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 800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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