Group:  Microsoft Word ยป microsoft.public.word.mail
Thread: Send To Recipient Problem in Word 2007

Send To Recipient Problem in Word 2007
Gary Bouchard 11/12/2008 8:02:06 PM
I am via automation, loading a Word2007 document, and sending the command to
send the document as the body of the email message ('Send to Recipient').

This is all working using outlooks automation on the Application_NewMail()
event that happens when new mail arrives.

The document gets sent to the Outlook 2007 Drafts folder, however it never
gets sent. I have tried sending the body as an html type document and the new
docx format with no difference.

After waiting over an hour to see if the mail would send, I opened the
message in the Drafts folder, saw the corrrectly formatted email address that
it was destined for, and the FROM address, and the subject, plus the document
embedded in the body.

I click on the send button, and it goes! I do notice an attachment called
header.html and if I open it the file, it is just long horizontal line.

This was working. I suspect something from Windows update, hotfixes and
patches had something to do with this problem however I am not sure when, so
I could back them off to see...

I can step through the automation code in Outlook and no errors are
generated, and the word object is set nothing after executing the .SEND
command.

I checked the task manager, and Winword is not running after the email is
placed in the Drafts folder.

is there some way to tell why the email item does not get sent?

I do have "Send Immediately" checked in the options, and any other email
sent directly from within Outlook as a "new message" are sent immediately.

Any help is appreciated.

Re: Send To Recipient Problem in Word 2007
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 11/12/2008 11:09:28 PM
I am not sure what code you are using to send the document, but the second
method in the article "How to send an email from Word using VBA" at:

http://www.word.mvps.org/FAQs/InterDev/SendMail.htm

works for me, or at least as it is modified in the article "Mail Merge to
E-mail with Attachments" at:

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Gary Bouchard" <GaryBouchard[ at ]discussions.microsoft.com> wrote in message
news:01BAC392-E143-4A74-A73A-BEA793038F10[ at ]microsoft.com...
[Quoted Text]
>I am via automation, loading a Word2007 document, and sending the command
>to
> send the document as the body of the email message ('Send to Recipient').
>
> This is all working using outlooks automation on the Application_NewMail()
> event that happens when new mail arrives.
>
> The document gets sent to the Outlook 2007 Drafts folder, however it never
> gets sent. I have tried sending the body as an html type document and the
> new
> docx format with no difference.
>
> After waiting over an hour to see if the mail would send, I opened the
> message in the Drafts folder, saw the corrrectly formatted email address
> that
> it was destined for, and the FROM address, and the subject, plus the
> document
> embedded in the body.
>
> I click on the send button, and it goes! I do notice an attachment called
> header.html and if I open it the file, it is just long horizontal line.
>
> This was working. I suspect something from Windows update, hotfixes and
> patches had something to do with this problem however I am not sure when,
> so
> I could back them off to see...
>
> I can step through the automation code in Outlook and no errors are
> generated, and the word object is set nothing after executing the .SEND
> command.
>
> I checked the task manager, and Winword is not running after the email is
> placed in the Drafts folder.
>
> is there some way to tell why the email item does not get sent?
>
> I do have "Send Immediately" checked in the options, and any other email
> sent directly from within Outlook as a "new message" are sent immediately.
>
> Any help is appreciated.
>


Re: Send To Recipient Problem in Word 2007
Gary Bouchard 11/13/2008 2:32:01 PM
Doug,

Very inciteful... thank you for the information. For more clarification, the
Word automation is initiated in Outlook 2007. When Outlook recieves an email,
it kick off an Application_NewMail() function/event which is where everything
starts...

Basically what I am doing is grabbing a CSV file (feedback response file)
from a website and bringing it into memory, parsing the information out of it
to retrieve the persons name and email address. I use a distribution list in
Outlook to store these names and email addresses, so I add them to the
Distlist (by the way, I am also using Outlook Redemption so I don't get the
security prompts).

I already have a document (which is a musicians performance calendar) done
in Word 2007 DOCX format (and also an HTML format), and use Sue Moshers's
example of automating Word to use the Document as the body, set up an
envelope to provide the name and email address it's going to, and then the
send. Here is the function that does this;
______________________________________________________
Sub SendCalendar()
Dim wd As Word.Application
Dim doc As Word.Document
Dim itm As Object
Dim ID As String
Dim blnWeOpenedWord As Boolean

On Error Resume Next
Set wd = GetObject(, "Word.Application")
On Error GoTo ErrHandler
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
blnWeOpenedWord = True
End If
Set doc =
wd.Documents.Open(FileName:="C:\Users\Administrator\Documents\Calendar for
John Winters.docx", ReadOnly:=False)
doc.MailEnvelope.Introduction = "This email is your confirmation for being
added to the calendar list. Below you will find the currently published
calendar. Please add this email address to your Safe Senders List."
Set itm = doc.MailEnvelope.Item
With itm
.To = CalCheck.EmailAddress
.SentOnBehalfOfName = "gary.bouchard[ at ]XXXXXXXX.net" (of course real
address used here)
.Subject = "John Winters Email Calendar confirmation"
.Save
ID = .EntryID
End With
Set itm = Application.Session.GetItemFromID(ID)
itm.Recipients.ResolveAll
itm.Send
doc.Close
If blnWeOpenedWord Then
wd.Quit
End If
Set doc = Nothing
Set itm = Nothing
Set wd = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, vbCritical + vbOKOnly, "CalCheck.SendCalendar"
Set doc = Nothing
Set itm = Nothing
Set wd = Nothing
End Sub
_________________________________________________________________

Watching the code execute, there are no errors, and when the .Send function
is hit, the message shows up the Outlook Drafts folder, ready to go, but it
never gets sent.

Perhaps I am missing a step?

"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> I am not sure what code you are using to send the document, but the second
> method in the article "How to send an email from Word using VBA" at:
>
> http://www.word.mvps.org/FAQs/InterDev/SendMail.htm
>
> works for me, or at least as it is modified in the article "Mail Merge to
> E-mail with Attachments" at:
>
> http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>

Re: Send To Recipient Problem in Word 2007
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 11/13/2008 7:30:17 PM
This is just a stab at it, but try replacing

With itm
.To = CalCheck.EmailAddress
.SentOnBehalfOfName = "gary.bouchard[ at ]XXXXXXXX.net" (of course real
address used here)
.Subject = "John Winters Email Calendar confirmation"
.Save
ID = .EntryID
End With
Set itm = Application.Session.GetItemFromID(ID)
itm.Recipients.ResolveAll
itm.Send

with

With itm
.To = CalCheck.EmailAddress
.SentOnBehalfOfName = "gary.bouchard[ at ]XXXXXXXX.net" (of course real
address used here)
.Subject = "John Winters Email Calendar confirmation"
' .Save
ID = .EntryID
.Recipients.ResolveAll
.Send
End With

Probably without the Save as I would guess that is what is putting the
message into the Drafts folder and with your original code, I am not sure
that you end up with the same object when the following lines of code are
executed

End With
Set itm = Application.Session.GetItemFromID(ID)


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Gary Bouchard" <GaryBouchard[ at ]discussions.microsoft.com> wrote in message
news:7793E61E-FC87-40EF-8CAD-7CCFD082A8C7[ at ]microsoft.com...
[Quoted Text]
> Doug,
>
> Very inciteful... thank you for the information. For more clarification,
> the
> Word automation is initiated in Outlook 2007. When Outlook recieves an
> email,
> it kick off an Application_NewMail() function/event which is where
> everything
> starts...
>
> Basically what I am doing is grabbing a CSV file (feedback response file)
> from a website and bringing it into memory, parsing the information out of
> it
> to retrieve the persons name and email address. I use a distribution list
> in
> Outlook to store these names and email addresses, so I add them to the
> Distlist (by the way, I am also using Outlook Redemption so I don't get
> the
> security prompts).
>
> I already have a document (which is a musicians performance calendar) done
> in Word 2007 DOCX format (and also an HTML format), and use Sue Moshers's
> example of automating Word to use the Document as the body, set up an
> envelope to provide the name and email address it's going to, and then the
> send. Here is the function that does this;
> ______________________________________________________
> Sub SendCalendar()
> Dim wd As Word.Application
> Dim doc As Word.Document
> Dim itm As Object
> Dim ID As String
> Dim blnWeOpenedWord As Boolean
>
> On Error Resume Next
> Set wd = GetObject(, "Word.Application")
> On Error GoTo ErrHandler
> If wd Is Nothing Then
> Set wd = CreateObject("Word.Application")
> blnWeOpenedWord = True
> End If
> Set doc =
> wd.Documents.Open(FileName:="C:\Users\Administrator\Documents\Calendar for
> John Winters.docx", ReadOnly:=False)
> doc.MailEnvelope.Introduction = "This email is your confirmation for being
> added to the calendar list. Below you will find the currently published
> calendar. Please add this email address to your Safe Senders List."
> Set itm = doc.MailEnvelope.Item
> With itm
> .To = CalCheck.EmailAddress
> .SentOnBehalfOfName = "gary.bouchard[ at ]XXXXXXXX.net" (of course real
> address used here)
> .Subject = "John Winters Email Calendar confirmation"
> .Save
> ID = .EntryID
> End With
> Set itm = Application.Session.GetItemFromID(ID)
> itm.Recipients.ResolveAll
> itm.Send
> doc.Close
> If blnWeOpenedWord Then
> wd.Quit
> End If
> Set doc = Nothing
> Set itm = Nothing
> Set wd = Nothing
> Exit Sub
> ErrHandler:
> MsgBox Err.Description, vbCritical + vbOKOnly, "CalCheck.SendCalendar"
> Set doc = Nothing
> Set itm = Nothing
> Set wd = Nothing
> End Sub
> _________________________________________________________________
>
> Watching the code execute, there are no errors, and when the .Send
> function
> is hit, the message shows up the Outlook Drafts folder, ready to go, but
> it
> never gets sent.
>
> Perhaps I am missing a step?
>
> "Doug Robbins - Word MVP" wrote:
>
>> I am not sure what code you are using to send the document, but the
>> second
>> method in the article "How to send an email from Word using VBA" at:
>>
>> http://www.word.mvps.org/FAQs/InterDev/SendMail.htm
>>
>> works for me, or at least as it is modified in the article "Mail Merge to
>> E-mail with Attachments" at:
>>
>> http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>


Home | Search | Terms | Imprint
Newsgroups Reader