Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jack - 19 Apr 2006 19:47 GMT
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.
Jean-Guy Marcil - 19 Apr 2006 21:43 GMT
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?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

jack - 19 Apr 2006 22:04 GMT
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 = "johnk@techaffinity.com"
   .CC = "johnk@techaffinity.com"
   .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

> jack was telling us:
> jack nous racontait que :
[quoted text clipped - 8 lines]
>     http://word.mvps.org/faqs/interdev/sendmail.htm
> for some ideas?
Jean-Guy Marcil - 19 Apr 2006 22:27 GMT
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

<snip>

> With oItem
>    .To = "johnk@techaffinity.com"
>    .CC = "johnk@techaffinity.com"
>    .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

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.