Solved

codes to insert image in outlook

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBScript - Find file starting with XXXX use that in runnig rest of code 9 78
VBA error replacing data 6 40
VBA filters 2 61
Access 2013 combo box not working 3 44
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

773 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