Inserting Images into Lotus Notes Email

santeria

Well-known Member
Joined
Oct 7, 2003
Messages
1,844
Finally I have the code all okay for Sending Reports, and other extra comments etc...

And now...
Is there code available for picking up images ( Screen snaps) and inserting into an email in Notes after the Body of the Message?

Either a reference to a link or some code would be greatly appreciated, cos I cannot find any info at this point in the archives ( Presuming I have searched using proper parameters ).

Ta

(y)
 
Anyways, the key problem for me is that the new Code in this thread is great and all, but it's Fundamentally ( as far as I can see) different to the email code as before, which you wrote, and I tweaked a little, and got it behaving great, but it was your code that did the job.

This New Code works great n all, but seems principally focused on the Image send.

The Attachment Component in the Code I have ,runs separately, but relies on the second email component.

As in :

Code:
Sub MultiSendFunctioneod()
Call SendNotesMail("TEST:Please Reply if Received;CMS Daily Report For " & Format(Date, "dddddd"), _
    "M:\REPORTS\02_FEBRUARY SUMMARY\CMS DAILY.xls", _
    Array("Name/Domain/Dom@DOM"), _
    Replace("CMS Daily Report for " & Format(Date, "dd/mm/yyyy") & Application.Rept(vbLf, 5) _
    & "Regards,|Name", "|", vbNewLine), _
    True)
End Sub

And works Brill.

What I am trying to assess, which I can't thus far, is, can the import of image code be brought in by a similar sub.
That would be cool, however, it seems that if you bring in images, it affects the whole macro.

I am also trying to Import a txt file with each email.

So the Defined Email would have the Main Recipient, the Group Email ( Defined in SendNotesMail in the code I have), and then Attach a file, then my txt comments imported, then the image files ( 2 at this stage).

If you could advise on that, I would greatly appreciate it.


Ta

(y)
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Okay, as a for example... this is a try to amalgamate, but fails on the first sub calling the attachment:

Code:
Sub MultiSendFunctioneod()
Call SendNotesMail("TEST:Please Reply if Received;CMS Daily Report For " & Format(Date, "dddddd"), _
    "M:\REPORTS\02_FEBRUARY SUMMARY\CMS DAILY.xls", _
    Array("Nam/Domain/dom@dom"), _
    Replace("CMS Daily Report for " & Format(Date, "dd/mm/yyyy") & Application.Rept(vbLf, 5) _
    & "Regards,|Name", "|", vbNewLine), _
    True)
Call SENDIMAGESBYMAIL
End Sub
Sub SENDCMSIMAGESBYMAIL()
Dim MyPic1 As Object, MyPic2 As Object
Application.ScreenUpdating = False
Set MyPic1 = ActiveSheet.Pictures.Insert( _
    "M:\EXPORTS\02_FEBRUARY\CMS\DAILY\1.jpg")
Set MyPic2 = ActiveSheet.Pictures.Insert( _
    "M:\EXPORTS\02_FEBRUARY\CMS\DAILY\2.jpg")
Call SendMail(MyPic1, MyPic2)
MyPic1.Delete: MyPic2.Delete
Set MyPic1 = Nothing: Set MyPic2 = Nothing
Application.ScreenUpdating = True
End Sub

Private Sub SendNotesMail(ByRef MyPic1 As Object, ByRef MyPic2 As Object, Subject As String, Attachment As String, _
    Recipient As Variant, BodyText As String, SaveIt As Boolean)

Dim Session As Object, Maildb As Object, MailDoc As Object
Dim AttachMe As Object, EmbedObj As Object
Dim UserName As String, MailDbName As String

Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, _
    (Len(UserName) - InStr(1, UserName, " "))) & "Name.nsf"

Set Maildb = Session.GetDataBase(vbNullString, MailDbName)
If Not Maildb.IsOpen Then Maildb.OPENMAIL

Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SaveMessageOnSend = SaveIt

If Not Attachment = vbNullString Then
    Set AttachMe = MailDoc.CreateRichTextItem("Attachment")
    Set EmbedObj = AttachMe.EmbedObject(1454, _
        vbNullString, Attachment, "Attachment")
    MailDoc.CreateRichTextItem ("Attachment")
End If

MailDoc.PostedDate = Now
Call MailDoc.Send(False)

Set Maildb = Nothing: Set MailDoc = Nothing: Set AttachMe _
    = Nothing: Set EmbedObj = Nothing: Set Session = Nothing
End Sub


Any hope for a sign of life ? :)

Ta

(y)
 
Upvote 0
Hello again, try the following:

<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> test()
<SPAN style="color:darkblue">Dim</SPAN> MyPic1 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, MyPic2 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
Application.ScreenUpdating = <SPAN style="color:darkblue">False</SPAN>
<SPAN style="color:darkblue">Set</SPAN> MyPic1 = ActiveSheet.Pictures.Insert( _
    "C:\Temp\Pic1.jpg")
<SPAN style="color:darkblue">Set</SPAN> MyPic2 = ActiveSheet.Pictures.Insert( _
    "C:\Temp\Pic2.jpg")
<SPAN style="color:darkblue">Call</SPAN> SendMail(MyPic1, MyPic2)
MyPic1.Delete: MyPic2.Delete
<SPAN style="color:darkblue">Set</SPAN> MyPic1 = Nothing: <SPAN style="color:darkblue">Set</SPAN> MyPic2 = <SPAN style="color:darkblue">Nothing</SPAN>
Application.ScreenUpdating = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN>

<SPAN style="color:darkblue">Private</SPAN> <SPAN style="color:darkblue">Sub</SPAN> SendMail(<SPAN style="color:darkblue">ByRef</SPAN> MyPic1 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, <SPAN style="color:darkblue">ByRef</SPAN> MyPic2 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>)

<SPAN style="color:darkblue">Dim</SPAN> Notes <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, db <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, WorkSpace <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> UIdoc <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, AttachMe <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, EmbedObj <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> UserName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>, MailDbName <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">String</SPAN>

<SPAN style="color:darkblue">Set</SPAN> Notes = CreateObject("Notes.NotesSession")

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

<SPAN style="color:darkblue">Set</SPAN> db = Notes.GetDataBase(vbNullString, MailDbName)

<SPAN style="color:darkblue">Set</SPAN> WorkSpace = CreateObject("Notes.NotesUIWorkspace")
<SPAN style="color:darkblue">Call</SPAN> WorkSpace.ComposeDocument(, , "Memo")

<SPAN style="color:darkblue">Set</SPAN> UIdoc = WorkSpace.CurrentDocument
<SPAN style="color:darkblue">Call</SPAN> UIdoc.FieldSetText("SendTo", "John H Deere") <SPAN style="color:green">'Recipient</SPAN>
<SPAN style="color:darkblue">Call</SPAN> UIdoc.FieldSetText("Subject", "Pic Time")

<SPAN style="color:darkblue">Call</SPAN> UIdoc.GotoField("Body")
<SPAN style="color:darkblue">Call</SPAN> UIdoc.InsertText(WorksheetFunction.Substitute( _
    "Hey Buddy,@@Check out the pics eh!@@", _
    "@", vbCrLf))

MyPic1.Copy: <SPAN style="color:darkblue">Call</SPAN> UIdoc.Paste

<SPAN style="color:darkblue">Call</SPAN> UIdoc.InsertText(WorksheetFunction.Rept(vbCrLf, 2))

MyPic2.Copy: <SPAN style="color:darkblue">Call</SPAN> UIdoc.Paste

<SPAN style="color:darkblue">Call</SPAN> UIdoc.InsertText(Application.Substitute( _
    "@@Don<SPAN style="color:green">'t Be A Stranger,@Moi", "@", vbCrLf))</SPAN>
Application.CutCopyMode = <SPAN style="color:darkblue">False</SPAN>

<SPAN style="color:darkblue">Set</SPAN> AttachMe = UIdoc.document.CreateRichtextitem("Attachment")

<SPAN style="color:darkblue">Set</SPAN> EmbedObj = AttachMe.EmbedObject(1454, _
    vbNullString, "c:\temp\test.bat", "Attachment")

UIdoc.document.posteddate = Now
<SPAN style="color:darkblue">Call</SPAN> UIdoc.Send(False)
<SPAN style="color:darkblue">Call</SPAN> UIdoc.<SPAN style="color:darkblue">Close</SPAN>

<SPAN style="color:darkblue">Set</SPAN> UIdoc = Nothing: <SPAN style="color:darkblue">Set</SPAN> WorkSpace = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> db = Nothing: <SPAN style="color:darkblue">Set</SPAN> Notes = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> EmbedObj = Nothing: <SPAN style="color:darkblue">Set</SPAN> AttachMe = <SPAN style="color:darkblue">Nothing</SPAN>

<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>

Regarding the spell checker, I might be tempted to reverse engineer Notes and delete this functionality on a permanent basis so as not to irritate myself to a point of no return. :LOL:
 
Upvote 0
Ta

I'll Give that a Try.

Time for a Caffeine break right now.

Did the code you built in have a txt file import option...

Just asking, I'm seeing double at the moment :)


Ta

(y)
 
Upvote 0
It fails on the Address.
The Bulk of What I was originally tagging to Email was sent with one line in Brackets after Call SendNotesMail.

The sequential file stuff sort of makes sense, but not in how to apply in this case.

Anyways, I'll try some variations.
It's just dying currently, after the images are Inserted, as well as the Subject text.
Point of death is at the "No address to send to" .

Mmmm, not real clear on what is happening, but oh so close.


Ta

(y)
 
Upvote 0
Look for:

Call UIdoc.FieldSetText("SendTo", "John H Deere") 'Recipient

Half-way through, and change John H Deere to something that's actually valid. :)
 
Upvote 0
I tried to see where I could insert

Code:
Call SendNotesMail("CMS EOD Report For " & Format(Date - 1, "dddddd"), _
    "M:\REPORTS\01_FEBRUARY SUMMARY\CMS DAILY.xls", _
    Array("Name/Domain/dom@dom")

Or some such variation...

But nothing seemed to work.
These comments pretty much seem to make the other Macro Work.
But the Goal is to not only attach a XLS file for sending, also attach 2 image files, but also insert a comment text file before the images.

Is that do-able ?


Ta

(y)
 
Upvote 0

Forum statistics

Threads
1,217,428
Messages
6,136,572
Members
450,021
Latest member
Jlopez0320

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top