Page 1 of 1 1
Topic Options
#74997 - 2003-05-13 06:08 PM Two attachments in an email sent from kix..
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
How can I add two attachments into an email? I pulled this code from this site..
Send mail through kix

Here's how I tried to do it, but it only attaches the first attachment.
code:
 
break on
:Email
$Root = CreateObject("Outlook.Application")
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
$MailItem.Subject = "Someheader"
$MailItem.To = "me@@mydomain.com"
$MailItem.Body = "SomeText for the body"
$MailItem.Attachments.Add("PathToFile1")
$MailItem.Attachments.Add("PathToFile2")
$MailItem.Body = "This is a test.@CRLF@CRLF"
$MailItem.Send
$Root = 0

Thanks in advance...L8tr..

Top
#74998 - 2003-05-13 08:20 PM Re: Two attachments in an email sent from kix..
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
We get some insight from -
Attachments Object

quote:

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.

Try this:

code:
break on
:Email
$Root = CreateObject("Outlook.Application")
$MailItem = $Root.CreateItem(0)
$MailItem.Importance = 1
$MailItem.Subject = "Someheader"
$MailItem.To = "me@@mydomain.com"
$MailItem.Body = "SomeText for the body"
$MailItem.Attachments.Add("PathToFile1")
$MailItem.Save
$MailItem.Attachments.Add("PathToFile2")
$MailItem.Body = "This is a test.@CRLF@CRLF"
$MailItem.Send
$Root = 0

Please reply if this works as I will update the FAQ with this info.

HTH,

Kent

[ 13. May 2003, 21:00: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74999 - 2003-05-13 08:30 PM Re: Two attachments in an email sent from kix..
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
That worked like a charm I didn't have to put the save after the second attachments.add line though.

You are da man!!

Thanks.. [Big Grin]

[ 13. May 2003, 20:32: Message edited by: cmarti ]

Top
#75000 - 2003-05-13 09:06 PM Re: Two attachments in an email sent from kix..
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
cmarti,

Thanks and I have updated my above response as well as the FAQ.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.045 seconds in which 0.019 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org