Solved

codes to insert image in outlook

Posted on 2006-11-09
6
250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

895 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

13 Experts available now in Live!

Get 1:1 Help Now