attached .doc file in word macro, but attachment is not received

J

jack

I wrote a macro to send a email with attachment using outlook object but when
the outlook object is displayed, it displays the attachment with broken icon
and when sent, the attachment is not received.
 
J

Jean-Guy Marcil

jack was telling us:
jack nous racontait que :
I wrote a macro to send a email with attachment using outlook object
but when the outlook object is displayed, it displays the attachment
with broken icon and when sent, the attachment is not received.

And the code you are using for the attachment/sending is....?

Meanwhile, have you looked at
http://word.mvps.org/faqs/interdev/sendmail.htm
for some ideas?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

jack

Thanks for your response. Pls find the code. It was earlier working, for some
reason, it takes my attachment as .lnk and does not sent the attachment due
to restrictions in sending .lnks in setup.

Any help is greatly appreciated. Thanks again.

Private Sub CommandButton1_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Object
Dim oItem As Object

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")

If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.Subject = ActiveDocument.FullName
.Attachments.Add ActiveDocument.FullName, olByValue, 1, "Document as
attachment"
.Display
End With

If bStarted Then
'If we started Outlook from code, then close it
oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
 
J

Jean-Guy Marcil

jack was telling us:
jack nous racontait que :
Thanks for your response. Pls find the code. It was earlier working,

You mean earlier as in "This morning" or as in "an earlier version of
Office"???
for some reason, it takes my attachment as .lnk and does not sent the
attachment due to restrictions in sending .lnks in setup.

What setup are you referring to?

Outlook is not more secure and prevents other program from manipulating the
sending of emails or the access to its address book.

For more on this, see:
http://www.slipstick.com/outlook/esecup/admin.htm
and
http://www.dimastr.com/redemption/
for a nice workaround to these restrictions

With oItem
.To = "(e-mail address removed)"
.CC = "(e-mail address removed)"
.Subject = ActiveDocument.FullName

Make sure the document as been saved or it will not work.
.Attachments.Add ActiveDocument.FullName, olByValue, 1, "Document as
attachment"
.Display
End With


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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