Solved

codes to insert image in outlook

Posted on 2006-11-09
6
254 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
ID: 17905250
0
 

Author Comment

by:Yannie
ID: 17906489
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
ID: 17912024
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
ID: 17943717
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
ID: 17984062
Closed, 500 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 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