Re: scripting message with attachment



Hi Sue,

Thank you for your response. However, the link you provided takes me to two
redirect pages and at the final page it crashes out both I.E. and Firefox.

Do you happen to have another link with the same info?

--Ali

"Sue Mosher [MVP-Outlook]" wrote:

Outlook doesn't know anything about files. You either have to know the name or use FileSystemObject or other methods to determine the file name. See http://msdn.microsoft.com/library/en-us/script56/html/jsfsotutor.asp for an FSO reference.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"ac2006" <ac2006@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:41482A1C-2C1C-4B93-8E90-95723ED9C0BE@xxxxxxxxxxxxxxxx
Hello,

I'd like to script sending a message with an attachment. I've found how to
do this when you know the attachment's name. But I need to script adding an
attachment when I don't know it's name.

The file I want to attach will always be located in C:\Reports and will
always be a PDF, but the name will change every day. I tried ATT =
"C:\Reports\*.pdf" but that didn't work.

I copied this script from a site and modified it for my needs, I really
don't know anything about scripting. Any help would be appreciated. Thank
you.

RCP = "recipent@xxxxxxxxxx"
MSG = "Test message"
SUBJ = "Test subject"
ATT = "C:\Reports\Attachment.pdf"

Set Outlook = CreateObject("Outlook.Application")
Set MAPI = Outlook.GetNameSpace("MAPI")
Set NewMail = Outlook.CreateItem(0)
NewMail.Subject = SUBJ
NewMail.Body = MSG
NewMail.Recipients.Add RCP
NewMail.Attachments.Add ATT

NewMail.Send

.



Relevant Pages

  • Re: Possible to create rule that uses keywords located in a text f
    ... Sue Mosher, Outlook MVP ... I think I can have the script reference a text file with the words I ... Dim msg As Outlook.MailItem ... Set olNS = Application.GetNamespace ...
    (microsoft.public.outlook.program_vba)
  • Re: Possible to create rule that uses keywords located in a text f
    ... Sue Mosher, Outlook MVP ... I think I can have the script reference a text file with the words I ... Dim msg As Outlook.MailItem ... Set olNS = Application.GetNamespace ...
    (microsoft.public.outlook.program_vba)
  • [NT] Flaw in Windows Script Engine Could Allow Code Execution
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... The Windows Script Engine provides Windows operating systems with the ... blocked by Outlook Express 6.0 and Outlook 2002 in their default ...
    (Securiteam)
  • Re: How do I get Outlook2003 to stop removing images(Outlook consi
    ... I'm not familiar enough with that utility to know if the script errors can ... Teach Yourself Outlook 2003 in 24 Hours ... Google and Other Search Engines (Visual QuickStart Guide) ... > what I would consider 'clean' images and content,i.e. ...
    (microsoft.public.outlook.general)
  • RE: How to manage profiles???
    ... Thereare two ways you can make Outlook work for roaming users, ... Other options are a proper network-aware email client, ... We run a script when a user logs on that maps their "home" drive. ...
    (microsoft.public.security)

Loading