Here is the code I am using. I found this somewhere on the net and I can't
find it again......It does the copy paste part perfect. the part it doesn't
do is send it to the correct person. It replies to an email in my in box
instead of creating a new email. Sorry if the ciode is a mess but I am new
at this and I was getting help from co-workers who are a little more
expierenced but they are stummped too
Thanks
Sub CopyRange()
' setting up various objects
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 EmbedObj1 As Object
Dim recipient As String
Dim ccRecipient As String
Dim bccRecipient As String
Dim subject As String
Dim bodytext As String
Dim Attachment1 As String
'Dim t1 As Range
t1 = Range("body")
' setting up all sending recipients
recipient = "
[email protected]"
ccRecipient = ""
bccRecipient = ""
subject = "Excel to Lotus Test Mail"
bodytext = "Testing this.."
'// Lets check to see if form is filled in Min req =Recipient, Subject,
Body Text
If recipient = vbNullString Or subject = vbNullString Or bodytext =
vbNullString Then
MsgBox "Recipient, Subject and or Body Text is NOT SET!",
vbCritical + vbInformation
Exit Sub
End If
' creating a notes session
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
On Error Resume Next
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
' loading the lotus notes e-mail with the inputed data
With MailDoc
.SendTo = recipient
.copyto = ccRecipient
.blindcopyto = bccRecipient
.subject = subject
.body = bodytext
End With
' saving message
MailDoc.SaveMessageOnSend = True
Attachment1 = ""
If Attachment1 <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM(Range("A1"))
Set EmbedObj1 = AttachME.EmbedObject(1454, "", Range("A1"),
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
' send e-mail !!!!
MailDoc.PostedDate = Now()
' if error in attachment or name of recipients
On Error GoTo errorhandler1
Range("body").Select
Selection.Copy
Set ws = CreateObject("Notes.NotesUIWorkspace")
If Not ws Is Nothing Then
Set uidoc = ws.editdocument(True)
If Not uidoc Is Nothing Then
If uidoc.editmode Then
Call uidoc.gotofield("Body")
Call uidoc.Paste
End If
End If
End If
'MailDoc.send 0, recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Range("A1")
'Unload Me
Exit Sub
' setting up the error message
errorhandler1:
MsgBox "Incorrect name supplied or the attachment has not attached," & _
"or your Lotus Notes has not opened correctly. Recommend you open up
Lotus Notes" & _
"to ensure the application runs correctly and that a vaild connection
exists"
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
' unloading the userform
'Unload Me
'saving data to external database
'linecount Macro
' Macro recorded 3/23/2010 by tb2841
'
End Sub