Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Posta via Lotus Notes-Incorporare immagini e link nel testo.

38 views
Skip to first unread message

Riccardo Baldinotti

unread,
Jul 12, 2010, 8:10:08 AM7/12/10
to
Sono nuovo di questo NG, ho cercato nei vecchi messaggi ma non sono
riuscito a trovare una risposta.
Sto cercando da VBA di produrre dei messaggi che vengano inviati con
Lotus Notes.
Finora, scopiazzando qua e là, ero riuscito a mettere testo con varie
formattazioni e font a seconda dei gusti.
Ora mi chiedono di mettere un'immagine come intestazione, di allineare
giustificato un paragrafo e di aggiungere un link ad un file.
La prima operazione, manualmente, si ottiene da Lotus su un nuovo memo
con Crea, Immagine, selezionando il file; la terza, selezionando del
testo, scegliendo Crea, Punto di attivazione, Collegamento e scrivendo
il percorso del file. Io però le devo produrre automaticamente
all'interno del mio codice.
Dopo tre giorni di ricerche in giro per il web, non mi resta che
chiedere aiuto per tutti e tre i bisogni.
Allego il codice fatto finora.
Grazie in anticipo.
Riccardo Baldinotti


Dim subject As String
Dim bodytxt As String
Dim mandali As String
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim AttachME As Object
Dim Session As Object
Dim EmbedObj As Object

Dim MyItem As Object
Dim MyStyle As Object
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName,
(Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
Else
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
Set MyItem = MailDoc.CREATERICHTEXTITEM("Body")
Set MyStyle = Session.CreateRichTextStyle

Set Rst = ... l'origine dei dati che devo scrivere nel
messaggio.
subject = "Newsletter direzionale del " & Rst!NLdata

rem qui vorrei inserrie un'immagine "t:\progetti\newsletter
\immagine.jpg"

Do
rem qui scrivo, in grassetto, il titolo dell'articolo
bodytxt = Rst!ARtitolo & vbCrLf
With MyItem
MyStyle.Bold = True
'MyStyle.Text.Left = True
Call MyItem.AppendStyle(MyStyle)
.appendtext bodytxt
End With
rem qui scrivo il riassunto. Vorrei giustificarlo.
bodytxt = Rst!ARabstract & vbCrLf
With MyItem
MyStyle.Bold = False
'MyStyle.Align.complete = True
Call MyItem.AppendStyle(MyStyle)
.appendtext bodytxt
End With
rrem questi sono i miei patetici tentativi di aggiungere un link
bodytxt = "<a href=" & Chr(34) & "t:\progetti\newsletter
\articolo.mht">Leggi articolo</a>" & vbCrLf & vbCrLf
With MyItem
MyStyle.Bold = False
'MyStyle.Alignment.Right = True
Call MyItem.AppendStyle(MyStyle)
.appendtext bodytxt
End With
Rst.MoveNext
Loop Until Rst.EOF

mandali = strIndirizzo
MailDoc.sendto = mandali
MailDoc.subject = subject
MailDoc.returnreceipt = "0"
MailDoc.SAVEMESSAGEONSEND = True
MailDoc.PostedDate = Now()
MailDoc.SEND 0, mandali
fine:
Set Rst = Nothing
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

Set MyImage = Nothing
Set MyLink = Nothing
Set MyObj = Nothing

Exit Sub

errore:
MsgBox Err.Number & " " & Err.Description & vbCrLf & "Invio
fallito"
GoTo fine:

Riccardo Baldinotti

unread,
Jul 21, 2010, 7:52:42 AM7/21/10
to
On 12 Lug, 14:10, Riccardo Baldinotti <barimo...@gmail.com> wrote:
> Sono nuovo di questo NG, ho cercato nei vecchi messaggi ma non sono
> riuscito a trovare una risposta.
> Sto cercando da VBA di produrre dei messaggi che vengano inviati con
> Lotus Notes.
Col seguente codice posso: Inserire un'immagine come intestazione del
messaggio; Formattare testo; Aggiungere collegamento a un documento
esterno.

Dim subject As String
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database
name
Dim MailDoc As Object 'The mail document itself
Dim Session As Object 'The notes session
Dim mandali As String

Dim richTextHeader As Object
Dim body As Object
Dim stream As Object

Set Session = CreateObject("Notes.NotesSession")

UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName)
- InStr(1, UserName, " "))) & ".nsf"

Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then

'Already open for mail
Else
Maildb.OPENMAIL
End If

Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"

Set stream = Session.CreateStream()

subject = "Newsletter direzionale"
' QUESTA È LA PARTE CHE METTE UN'IMMAGINE IN TESTA AL MESSAGGIO
Call stream.Open("percorso dell'immagine")
Set body = MailDoc.CreateMIMEEntity '("memo")
Set richTextHeader = body.CreateHeader("Content-Type") '
Call richTextHeader.SetHeaderVal("multipart/mixed")
Set mimeImage = body.CreateChildEntity()
strImageType = "image/jpeg" 'Other formats are "image/gif" "image/bmp"
Call mimeImage.SetContentFromBytes(stream, strImageType,
ENC_IDENTITY_BINARY)
Call stream.Close
' QUESTA È LA PARTE CHE AGGIUNGE IL TESTO
Set mimeHtml = body.CreateChildEntity()
Call stream.WriteText(fFaiPagina) 'ROUTINE CHE PRODUCE IL TESTO IN
FORMATO HTML
Call mimeHtml.SetContentFromText(stream, "text/
html;charset=iso-8859-1", ENC_IDENTITY_8BIT)
Call stream.Close

mandali = INDIRIZZO DEL DESTINATARIO


MailDoc.sendto = mandali
MailDoc.subject = subject
MailDoc.returnreceipt = "0"

MailDoc.SAVEMESSAGEONSEND = True

MailDoc.PostedDate = Now()

MailDoc.Send 0, mandali '

Set Rst = Nothing
Set Maildb = Nothing
Set MailDoc = Nothing

Set Session = Nothing
Set body = Nothing
Set stream = Nothing
Set richTextHeader = Nothing

Saluti
Riccardo Baldinotti

0 new messages