A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

scripting message with attachment



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 9th 08, 10:42 PM posted to microsoft.public.outlook.program_vba
ac2006
external usenet poster
 
Posts: 6
Default scripting message with attachment

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 = "
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
Ads
  #2  
Old April 10th 08, 01:55 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default scripting message with attachment

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...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" wrote in message ...
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 = "
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

  #3  
Old April 10th 08, 09:54 PM posted to microsoft.public.outlook.program_vba
ac2006
external usenet poster
 
Posts: 6
Default 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...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" wrote in message ...
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 = "
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


  #4  
Old April 10th 08, 10:09 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default scripting message with attachment

Well, I can't help it if Microsoft has changed their URLs once again. I got to the redirect page at http://msdn2.microsoft.com/en-us/library/d6dw7aeh.aspx with no problems.

--
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" wrote in message ...
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...jsfsotutor.asp for an FSO reference.



"ac2006" wrote in message ...
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 = "
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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Message As An Attachment JoeCL Outlook - Installation 1 August 23rd 06 05:05 PM
e-mail attachment message Julie Lindblad Outlook Express 6 July 21st 06 05:44 PM
Recieving a message with attachment and I can't view message body mytwosweetpeas Outlook - General Queries 0 July 7th 06 07:48 PM
See attachment line in new message? cjlatta Outlook - Installation 1 June 15th 06 11:16 PM
Adding attachment to message David Wendt Add-ins for Outlook 5 April 24th 06 02:28 PM


All times are GMT +1. The time now is 04:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.