NotesStream and File Attachments

I’m using the notesstream class to create an HTML based e-mail. It’s working fine with no problems. However, I’d like to take a file attachment from a richtextfield and include it on the e-mail. Can someone shed some light on how you go about accomplishing that?

Thanks

Subject: RE: NotesStream and File Attachments

You would have to detach it to disk, then use the NotesStream class to read the data (I assume you’re using the MIME classes to create the email body).

Subject: RE: NotesStream and File Attachments

If you export the document as DXL, then you can use XML processing classes to scan the DXL and get the binary data for the image. Or, you can use the Notes C API to read off the CD records and work it that way. Or, use a third-party tool such as Midas from www.geniisoft.com.

Alternatively, you can generate your emails as Notes rich text and let the email gateway convert them to MIME for you.

Subject: RE: NotesStream and File Attachments

Andre,Thanks for responding! If there is a graphic that is not attached but embedded into a document is it possible to detach that to a file? I didn’t think you could… We have people taking screenshots and pasting them to a field in a help database. What I’m trying to do is create an e-mail of the pertinent information and then send it over the internet. I was able to create the e-mail using an example that I think I found on notes.net. I would have used rich text classes where I could have grabbed the fields but it seemed more difficult to construct tables in the e-mail via RT classes instead of HTML. I really don’t know much about notesstream or MIME but that I’d give it a try. Only at the end did I realize that there didn’t seem an easy way to deal with attachments/embedded graphics.

The portion of the code that actually produces the e-mail is below.

Dim body As NotesMIMEEntity

Dim stream As NotesStream



session.ConvertMIME = False ' Do not convert MIME to rich text

Set stream = session.CreateStream

Set body = newdoc.CreateMIMEEntity



' Open the HTML (Title doesn't matter since it doesn't appear anywhere)

Call stream.WriteText ("<html><head><title>Sample HTML  email via MIME</title>")



' BEGIN: Inline Stylesheet

Call stream.WriteText (|

	 <style type="text/css">

	 <!--

	 .text, td, tr, p, br, body {

	 COLOR: #000000; 

	 FONT-FAMILY: Arial, Helvetica, sans-serif;

	 FONT-SIZE: 12px;

	 }

	 a {

	 font-family: Arial, Helvetica, sans-serif;

	 color: #000000;

	 FONT-WEIGHT: bold;

	 text-decoration: none;

	}



	 p {

	 font-family: Arial, Helvetica, sans-serif;

	 color: #000000;

	 FONT-WEIGHT: bold;

	 FONT-SIZE: 20px;

	 text-decoration: none;



	 -->

	 </style>

	|)

' END: Inline Stylesheet



Call stream.WriteText ({</head>})

Call stream.WriteText ({<body text="#666666" bgcolor="#FFFFFF"

leftmargin=“0” topmargin=“0” marginheight=“0” marginwidth=“0”>})

’ BEGIN: HTML body

Call stream.writetext({<H1><P align="CENTER">})



Call stream.writetext(description)

Call stream.writetext({</H1></P>})

Call stream.writetext("<BR><BR><BR>")





Call stream.WriteText ({

	<table width="100%" border="2" cellspacing="0" cellpadding="0"

	bgcolor="#FFFFFF"> })



Call stream.Writetext ({<tr>})

Call stream.writetext({<th> Created </th>})

If doc.form(0) = "Help" Then

	Call stream.writetext({<th> Caller Name </th>})

	Call stream.writetext({<th> Caller Phone </th>})

	Call stream.writetext({<th> Calling Method </th>})

End If



Call stream.writetext({<th> Assigned To </th>})

Call stream.writetext({<th> Status </th>})







Call stream.writetext ({ <tr> })

Call stream.writetext ({ <td> } & doc.taskdateentered(0) & {</td>})

If doc.form(0) = "Help" Then

	Call stream.writetext ({ <td> } & doc.hdcallername(0) & {</td>})

	Call stream.writetext ({ <td> } & doc.hdphonenumber(0) & {</td>})

	Call stream.writetext ({ <td> } & doc.hdoriginationmethod(0) & {</td>})

End If



Call stream.writetext ({ <td> } & doc.taskassignedto(0) & {</td>})

Call stream.writetext ({ <td> } & doc.status(0) & {</td>})



Call stream.writetext({</table>})



Call stream.writetext({<BR><BR><BR>})



Call stream.writetext({<table width="100%" border="2" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">})







Call stream.writetext({<TR>})

Call stream.writetext({<TD>} & "Recent Comments" & {</TD>})

Call stream.writetext({<TD>} & nrc & {</TD>})

Call stream.writetext({</TR>})

Call stream.writetext({<TR>})

Call stream.writetext({<TD>} & "Archived Comments" & {</TD>})

Call stream.writetext({<TD>} & nac & {</TD>})

Call stream.writetext({</TR>})

Call stream.writetext({</table>})









' END: HTML body

’ Close the HTML

Call stream.WriteText ({</body></html>})

’ Ensure the MIME content will be recognized as HTML (Must be after the stream is written)

Call body.SetContentFromText (stream, "text/html;charset=iso-8859-1", ENC_NONE) 







Call newdoc.Send(False)