Michael B. Smith <mich...@smithcons.com> wrote:

> I don’t consider myself a master-developer.
>
>
>

Well crap, that lowers my opinion of my own limited PowerShell skills even
further...... :)





On Wed, May 11, 2011 at 10:19 AM, Michael B. Smith <mich...@smithcons.com>wrote:

>  I’m not going to say that it can’t be done – I don’t consider myself a
> master-developer. But the interfaces don’t match. A CDO.Message attachment
> is (under-the-hood) an IBodyParts enumerated collection of IBodyPart. A
> Net.Mail attachment is either a URI (which may be a filename) or an IStream
> object. I don’t know how to map an IBodyPart to either an URI or an IStream.
>
>
>
> See if $attach has a GetStream() interface associated method. If so, you
> are golden. I’m not at a place I can check right now.
>
>
>
> Regards,
>
>
>
> Michael B. Smith
>
> Consultant and Exchange MVP
>
> http://TheEssentialExchange.com
>
>
>
> *From:* Joseph L. Casale [mailto:jcas...@activenetwerx.com]
> *Sent:* Wednesday, May 11, 2011 12:05 PM
> *To:* NT System Admin Issues
> *Subject:* Powershell help
>
>
>
> I am using Net.Mail.SMTPclient to send an email with an attatchment as
> Send-MailMessage doesn’t allow me to change the port.
>
> Before this, I parse an email in a IIS drop folder and extract the
> attachment (thanks for that Michael).
>
> As per Michael’s original email:
>
>
>
>     $adTypeText = 2
>
>     …
>
>     $objMail = New-Object –comobject "CDO.Message"
>
>     $objStream = $objMail.GetStream()
>
>     $objStream.type = $adTypeText
>
>     $objStream.LoadFromFile( "c:\file.eml" )
>
>     $objStream.Flush()
>
>     …
>
>     foreach( $attach in $objMail.Attachments )
>
>     {
>
>         $attach.Name
>
>     }
>
>     …
>
>     $objStream.Close()
>
>     $objStream = $null
>
>     $objMail = $null
>
>
>
> The code my sample script was using to manually attach a file for testing
> looks like:
>
> $attachment = new-object Net.Mail.Attachment($fileattachment)
>
> $msg.attachments.add($attachment)
>
> where I just $fileattachment = “<some path>”
>
>
>
> Is there a way to utilize the attachment from Michael’s code without first
> saving it to disc, but simply referencing it in the $attachment?
>
>
>
> Thanks!
> jlc
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to