I am trying to create Newsletter which contains some HTML text and Images. I also attach a word document to the NewsLetter. It works well with Lotus Client, Gmail and Outlook.When it comes to Yahoo and rediff, the images are shown as attachments and the HTML doesnt seem to contain the Images.
I have pasted the code for reference. Thanks in advance
On Error Goto errorhasoccured
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim parent As NotesMimeEntity
Dim child1 As NotesMimeEntity
Dim child2 As NotesMimeEntity
Dim child3 As NotesMimeEntity
Dim header As NotesMimeHeader
Dim dataDir As String
Dim stream As NotesStream
Dim prompt As String
Dim recipients As String
session.ConvertMime = False
Set db = session.CurrentDatabase
Set doc = db.CreateDocument
Call doc.ReplaceItemValue("Form", "Memo")
Call doc.ReplaceItemValue("Subject", "Doc created " & Format$(Now, "dd mmm yyyy hh:nn:ss AM/PM"))
datadir = "D:\Lotus\Domino\Data\EAP\P\P\"
Set parent = doc.CreateMIMEEntity
Set child3 = parent.CreateChildEntity
Set child2 = parent.CreateChildEntity(child3)
Set child1 = parent.CreateChildEntity(child2)
Set header = parent.GetNthHeader("Content-Type")
Call header.SetHeaderValAndParams({multipart/mixed; boundary="} & child1.BoundaryStart & {"})
Set header = child2.CreateHeader("Content-ID")
Call header.SetHeaderVal("<_1_" & doc.UniversalID & ">")
Set header = child2.CreateHeader("Content-Type")
Call header.SetHeaderVal("multipart/related")
Set stream = session.CreateStream
Call stream.WriteText({<table border="1" width="500" align="center">})
Call stream.WriteText({<tr><td>})
Call stream.WriteText({<img src=cid:_1_} & doc.UniversalID & {>})
Call stream.WriteText({</td></tr>})
Call stream.WriteText({<tr><td>})
Call stream.WriteText({<a href="cid:winword.doc">click here</a>})
Call stream.WriteText({</td></tr></table>})
Call child1.SetContentFromText(stream, "text/html", ENC_NONE)
Call stream.Truncate
Set stream = session.CreateStream
If Not stream.Open(dataDir & "calculator.jpg", "binary") Then
Msgbox "Could not open " & dataDir & "calculator.jpg", 16, "Open failed"
Goto errorhasoccured
End If
If stream.Bytes = 0 Then
Msgbox "File " & dataDir & "calculator.jpg" & " has no content", 16, "No Content"
Goto errorhasoccured
End If
Call child2.SetContentFromBytes(stream, "image/gif", ENC_NONE)
Call child2.EncodeContent(ENC_BASE64)
Call stream.Close
Set header = child3.createHeader("Content-Type")
Call header.setHeaderVal("multipart/related")
Set header = child3.createHeader("Content-Disposition")
Call header.setHeaderVal(|attachment; filename="winword.doc"|) '01-2005.doc should be replaced with the file name of the file you need to attach
Set header = child3.createHeader("Content-ID")
Call header.setHeaderVal(|<winword.doc>|)
Set stream = session.CreateStream()
If Not stream.Open("D:\Lotus\Domino\Data\EAP\P\P\winword.doc", "binary") Then
Print "Open failed"
End If
If stream.Bytes = 0 Then
Print "File has no content"
End If
Call child3.SetContentFromBytes(stream, "application/msword", ENC_IDENTITY_BINARY)
Call stream.Close
Call doc.Send(False, Split("123@gmail.com,123@yahoo.com,123@hotmail.com,123@rediffmail.com", ","))
Exit Sub
errorhasoccured:
Msgbox "error in Agent M3" & Error & Erl
Exit Sub