Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Notes: how to send a cc ?

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
CA
I have following code which works really well except I don't know how to send a cc. What should I replace "Sendcc" with ? What am I missing??

'Start Lotus Notes application

Const EMBED_ATTACHMENT = 1454

Set session = CreateObject("Notes.NotesSession")
Set db = session.GetDatabase("", "")
Call db.OpenMail

Set Doc = db.CreateDocument
msg = "Please find herewith ...." & vbCrLf & vbCrLf
msg2 = vbCrLf & vbCrLf & vbCrLf & "Thank you and have a nice day !"


Call Doc.ReplaceItemValue("SendTo", "mike .....")
Call Doc.ReplaceItemValue("Sendcc", "Dan....", "Rick......")
Call Doc.ReplaceItemValue("Subject", "Report for " & Date)

Set rtitem = Doc.CreateRichTextItem("Body")
Call rtitem.AppendText(msg)

MyAttachment = "C:\documents\...."

Call rtitem.EmbedObject(EMBED_ATTACHMENT, "", MyAttachment)
Call rtitem.AppendText(msg2)
Doc.SaveMessageOnSend = True
Call Doc.PutInFolder("BBSS")

Call Doc.Send(False)

Set session = Nothing
 
Haven't used Lotus Notes to send email before, but how about just "CC" ? That's what it is when sending email through Outlook.

If that doesn't work, maybe you could write a little test loop to list out all the ItemValue's for the Doc object. . .



VBAjedi [swords]
 
That does not work, I had tried it. Along with numerous others :)

Thanks

Mike
 
So can you do something like:
Code:
For each Doc.Item
   Debug.Print .Value
Next
to get a list of the various ItemValues? I suppose it's possible there is no default CC item, so you have to create it instead of just replacing it. . .

If that (or a similar loop) doesn't do it, I'll have to bow out. . . I don't have a silver bullet for you!

VBAjedi [swords]
 
Here is some code I use for sending email with attachment through Lotus Notes.
May be of some help.

Public Sub SendNotesEmail(Subject As String, Attachment As String, Recipient As String, ccRecipient As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes

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 AttachME As Object ' The attachement richtextfile object
Dim Session As Object ' The Notes Seesion
Dim EmbedObj As Object ' The Embedded Object (attachment)

' Start a session to notes

Set Session = CreateObject("Notes.NotesSession")

' Get the sessions username and then calculate the mail file name
' you may or may not need this as for MailDBName with some systems you
' can pass an empty sstring

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

' Open the mail database in notes

Set Maildb = Session.GETDATABASE("", MailDbName)

If Maildb.IsOpen = True Then
' already open for mail

Else
Maildb.OPENMAIL
End If

'Set up the new mail document

Set MailDoc = Maildb.CREATEDOCUMENT

MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.CopyTo = ccRecipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt

' Set up the embedded object and attachment and attach it

If Attachment <> &quot;&quot; Then

Set AttachME = MailDoc.CREATERICHTEXTITEM(&quot;ATTACHMENT&quot;)
Set EmbedObj = AttachME.embedobject(1454, &quot;&quot;, Attachment, &quot;ATTACHMENT&quot;)
MailDoc.CREATERICHTEXTITEM (&quot;Attachment&quot;)

End If


'Send the document

MailDoc.postedDate = Now() ' Gets the mail to appear in the sent items folder

MailDoc.send 0, Recipient

' Clean up

Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

End Sub


Regards

Paul
 
The one that works is simply &quot;CopyTo&quot;
Heaven forbid that Lotus should every adopt a consistent system of parameters !

Richard
 
Thanks everybody.

Really appreciated.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top