Solved

codes to insert image in outlook

Posted on 2006-11-09
6
249 Views
Last Modified: 2012-05-07
Hi all,

Under here is the codes for formatting and send out the mail. Everything is almost done EXCEPT the inserting of logo image to my mail body. I managed to find the codes on the net but after testing it is what i sort of wanted but I need slight modification. Please help...

Under the AddInfo(), it contains all the info I want in the body which will be printed out in text. Under the item_send() function, I need to have it printed out in
the picture2.jpg
then the greetings which is actually strMeseage. but it seems to be unable to display out the picture and strMessage and

How do I combine the picture with the strMessage body under the Item_Send()? Or shld I do the display in the strMessage? Help Help...

And it also seems these 2 objects are driving me crazy cos it opens up new mail..i do not want that..how to solve it?
Set objOL = CreateObject("Outlook.Application") <-----------------
Set objMail = objOL.CreateItem(olMailItem)<----------------------

Here are the codes..

=======================================
Function AddInfo()
     dim dept
     Set fmCtl = Item.GetInspector.ModifiedFormPages("Message").Controls("CardFormCtl1")
      dept = fmCtl.DeptName

        If dept <> "" Then
                strMessage = "Dear Clients & Friends" & vbCrLf _
                & vbCrLf _
                & "Season's greetings" & vbCrLf _
                & vbCrLf _
                & "Best regards" & vbCrLf _
                &  vbCrLf _
                & dept & vbCrLf _
            AddInfo = True
           Else
            AddInfo = False
           End If
     
     Set fmCtl = Nothing
End Function


Function Item_Send()
      Set objOL = CreateObject("Outlook.Application") <-----------------
          Set objMail = objOL.CreateItem(olMailItem)<---------------------- I don't need to create another new mail
          objMail.Attachments.Add "C:\picture2.jpg"
          objMail.HTMLBody = "<html><p>This is a picture.</p>" & _
                   "<img src='cid:picture2.jpg' height=50 width=500></p></html>"
      objMail.body = strMessage
      objMail.Display

       'If AddInfo() = True then
       'Item.subject = "Christmas Card"
       'Item.body = strMessage
       'Item.MessageClass = "IPM.Note"
       'end if

End Function
===========================================



0
Comment
Question by:Yannie
  • 3
6 Comments
 
LVL 6

Expert Comment

by:saravananvg
Comment Utility
0
 

Author Comment

by:Yannie
Comment Utility
Hmm it's almost the same..
now is i'm trying to consolidate..

I also had the objects created here..
Set objOL = CreateObject("Outlook.Application") <-----------------
         Set objMail = objOL.CreateItem(olMailItem)<----------------------  

If i dun use.createItem(), can i?
0
 

Author Comment

by:Yannie
Comment Utility
If i juz want to make it send out together under as objMail.send instead and remove item_send() is dat possible?
0
 

Author Comment

by:Yannie
Comment Utility
Ok I got it solved .

I can choose to

Item.Attachments.Add "c:\emailmasthead2.jpg"
Item.HTMLBody = "<html><img src='cid:emailmasthead2.jpg' height=50 width=500><p></html>"
Or      
Item.HTMLBody = "<html><img src='http://www.thisismysite.com/emailmasthead2.jpg' height=50 width=500><p></html>"

both works!
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
Comment Utility
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now