26
13 January 2107 Getting there… The only problem is that identified on 11 January, namely that the subroutines TestLaunchEmail and LaunchEmailEmbed work as part of the workbook ABPControl.xlsm, they do not work when copied to another workbook. In other workbooks, the system crashes at the line Dim LEMail As Outlook.MailItem I have narrowed the problem down to the fact that the following subroutine works in ABPControl.xlsm, but does not work in in other new .xlsms Sub testdim() Dim LEPath$ Dim LEMail As Outlook.MailItem MsgBox "This works" End Sub Both applications have the same tools reference (see below)

f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

13 January 2107

Getting there…

The only problem is that identified on 11 January, namely that the subroutines TestLaunchEmail and LaunchEmailEmbed work as part of the workbook ABPControl.xlsm, they do not work when copied to another workbook.

In other workbooks, the system crashes at the line

Dim LEMail As Outlook.MailItem

I have narrowed the problem down to the fact that the following subroutine works in ABPControl.xlsm, but does not work in in other new .xlsmsSub testdim()

Dim LEPath$

Dim LEMail As Outlook.MailItem

MsgBox "This works"

End Sub

Both applications have the same tools reference (see below)

The difference appears in the autofill situations

Page 2: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

When, in ABPControl.xlsm, I type “DIM LEMail as O” the autofill presented the following

In PublicLaunchEmail.xlsm it differs as outlook is not available. What I see is

w

This means that “outlook” objects don’t seem to be permitted in general, but are in ABPControl.xlsm

Tools reference comparison

ABPcontrol.xlsm

Page 3: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

Public LaunchEmail.xlsm

Page 4: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

12 January 2017

Having made Richard’s changes in the application that launches the email correctly, the HTMLbody as produced by the final line LEEMail.HTMLBody = LEEMail.HTMLBody & "<br><B>Embedded Image:</B><br>" & "<img src='" & LEEEmbed & "'" & " width='500' height='200'><br>" & "<br>Best Regards, <br>Sumit</font></span>"

which refers to the embedded file rather than 'cid:image.jpg as in Richard’s text. (below I use Richard’s exact text with a slightly different but still problematic result)

is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>

<HEAD>

<META NAME="Generator" CONTENT="MS Exchange Server version rmj.rmm.rup.rpr">

<TITLE></TITLE>

</HEAD>

<BODY>

<!-- Converted from text/rtf format -->

<P><FONT FACE="Calibri">This is a test of LaunchEmail putting the imageC:\Users\dbarton\Pictures\LOGOUBANK.JPG at default position dimensions width 500 , height 200</FONT></P>

Page 5: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

</BODY>

</HTML><br><B>Embedded Image:</B><br><img src='C:\Users\dbarton\Pictures\LOGOUBANK.JPG' width='500' height='200'><br><br>Best Regards, <br>Sumit</font></span>

This is a screen shot of the email display before I sent it

When I send the email, what I get in my inbox is as below

Page 6: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

I have confirmed that the file is correctly attached, even if not embedded.

This is the screen shot of the file from the attachment.

Page 7: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

This is the source code of the email I received

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}

o\:* {behavior:url(#default#VML);}

w\:* {behavior:url(#default#VML);}

.shape {behavior:url(#default#VML);}

</style><![endif]--><style><!--

/* Font Definitions */

@font-face

{font-family:"Cambria Math";

panose-1:2 4 5 3 5 4 6 3 2 4;}

@font-face

Page 8: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

{font-family:Calibri;

panose-1:2 15 5 2 2 2 4 3 2 4;}

/* Style Definitions */

p.MsoNormal, li.MsoNormal, div.MsoNormal

{margin:0cm;

margin-bottom:.0001pt;

font-size:12.0pt;

font-family:"Times New Roman",serif;}

a:link, span.MsoHyperlink

{mso-style-priority:99;

color:#0563C1;

text-decoration:underline;}

a:visited, span.MsoHyperlinkFollowed

{mso-style-priority:99;

color:#954F72;

text-decoration:underline;}

p

{mso-style-priority:99;

mso-margin-top-alt:auto;

margin-right:0cm;

mso-margin-bottom-alt:auto;

margin-left:0cm;

font-size:12.0pt;

font-family:"Times New Roman",serif;}

span.EmailStyle18

{mso-style-type:personal-compose;

font-family:"Calibri",sans-serif;}

.MsoChpDefault

{mso-style-type:export-only;

font-size:10.0pt;}

@page WordSection1

Page 9: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

{size:612.0pt 792.0pt;

margin:72.0pt 72.0pt 72.0pt 72.0pt;}

div.WordSection1

{page:WordSection1;}

--></style><!--[if gte mso 9]><xml>

<o:shapedefaults v:ext="edit" spidmax="1027" />

</xml><![endif]--><!--[if gte mso 9]><xml>

<o:shapelayout v:ext="edit">

<o:idmap v:ext="edit" data="1" />

</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link="#0563C1" vlink="#954F72"><div class=WordSection1><p><span style='font-family:"Calibri",sans-serif'>This is a test of LaunchEmail putting the imageC:\Users\dbarton\Pictures\LOGOUBANK.JPG at default position dimensions width 500 , height 200</span><o:p></o:p></p><p class=MsoNormal><br><b>Embedded Image:</b><br><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">

<v:stroke joinstyle="miter" />

<v:formulas>

<v:f eqn="if lineDrawn pixelLineWidth 0" />

<v:f eqn="sum @0 1 0" />

<v:f eqn="sum 0 0 @1" />

<v:f eqn="prod @2 1 2" />

<v:f eqn="prod @3 21600 pixelWidth" />

<v:f eqn="prod @3 21600 pixelHeight" />

<v:f eqn="sum @0 0 1" />

<v:f eqn="prod @6 1 2" />

<v:f eqn="prod @7 21600 pixelWidth" />

<v:f eqn="sum @8 21600 0" />

<v:f eqn="prod @7 21600 pixelHeight" />

<v:f eqn="sum @10 21600 0" />

</v:formulas>

<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" />

<o:lock v:ext="edit" aspectratio="t" />

Page 10: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

</v:shapetype><v:shape id="AutoShape_x0020_1" o:spid="_x0000_s1026" type="#_x0000_t75" style='width:375pt;height:150pt;visibility:visible;mso-left-percent:-10001;mso-top-percent:-10001;mso-position-horizontal:absolute;mso-position-horizontal-relative:char;mso-position-vertical:absolute;mso-position-vertical-relative:line;mso-left-percent:-10001;mso-top-percent:-10001'>

<w:wrap type="none"/>

<w:anchorlock/>

</v:shape><![endif]--><![if !vml]><img width=500 height=200 src="cid:[email protected]" v:shapes="AutoShape_x0020_1"><![endif]><br><br>Best Regards, <br>Sumit<o:p></o:p></p></div></body></html>

When I use Richard’s exact code,LEEMail.HTMLBody = LEEMail.HTMLBody & "<br><B>Embedded Image:</B><br>" & "<img src='cid:image.jpg'" & LEEEmbed & "'" & " width='500' height='200'><br>" & "<br>Best Regards, <br>Sumit</font></span>"

I see this

Page 11: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

,

When I send an ordinary test email, i see

Page 12: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

And the source code looks like <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}

o\:* {behavior:url(#default#VML);}

w\:* {behavior:url(#default#VML);}

.shape {behavior:url(#default#VML);}

</style><![endif]--><style><!--

/* Font Definitions */

@font-face

{font-family:"Cambria Math";

panose-1:2 4 5 3 5 4 6 3 2 4;}

@font-face

Page 13: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

{font-family:Calibri;

panose-1:2 15 5 2 2 2 4 3 2 4;}

/* Style Definitions */

p.MsoNormal, li.MsoNormal, div.MsoNormal

{margin:0cm;

margin-bottom:.0001pt;

font-size:11.0pt;

font-family:"Calibri",sans-serif;

mso-fareast-language:EN-US;}

a:link, span.MsoHyperlink

{mso-style-priority:99;

color:#0563C1;

text-decoration:underline;}

a:visited, span.MsoHyperlinkFollowed

{mso-style-priority:99;

color:#954F72;

text-decoration:underline;}

span.EmailStyle17

{mso-style-type:personal-compose;

font-family:"Calibri",sans-serif;

color:windowtext;}

.MsoChpDefault

{mso-style-type:export-only;

font-family:"Calibri",sans-serif;

mso-fareast-language:EN-US;}

@page WordSection1

{size:612.0pt 792.0pt;

margin:72.0pt 72.0pt 72.0pt 72.0pt;}

div.WordSection1

{page:WordSection1;}

--></style><!--[if gte mso 9]><xml>

Page 14: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

<o:shapedefaults v:ext="edit" spidmax="1026" />

</xml><![endif]--><!--[if gte mso 9]><xml>

<o:shapelayout v:ext="edit">

<o:idmap v:ext="edit" data="1" />

</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>ASDFG<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'>&nbsp;<o:p></o:p></span></p><table class=MsoNormalTable border=0 cellpadding=0 width="100%" style='width:100.0%'><tr><td width="8%" rowspan=4 style='width:8.1%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal style='line-height:105%'><span style='mso-fareast-language:EN-AU'><img width=59 height=83 id="Picture_x0020_4" src="cid:[email protected]" alt="201506 Dennis Barton"></span><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="15%" style='width:15.18%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal style='line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>Dennis Barton&nbsp; Director</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="25%" style='width:25.32%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon'>Level&nbsp;8 251 Adelaide Terrace Perth Western Australia</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif'><o:p></o:p></span></p></td><td width="10%" rowspan=4 style='width:10.12%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:105%'><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><img width=59 height=63 id="Picture_x0020_2" src="cid:[email protected]"></span><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif'><o:p></o:p></span></p></td><td width="40%" style='width:40.5%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><b><span style='font-size:18.0pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>Barton Consultancy</span></b><span style='font-size:18.0pt;line-height:105%;font-family:"Times New Roman",serif;color:#256109;mso-fareast-language:EN-AU'> </span><b><span style='font-size:10.0pt;line-height:105%;font-family:"Times New Roman",serif;color:#882124;mso-fareast-language:EN-AU'>Pty Ltd </span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td></tr><tr><td width="15%" style='width:15.18%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal style='line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>+61 417 937 854</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="25%"

Page 15: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

style='width:25.32%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>PO Box 3584 East Perth 6892</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="40%" rowspan=2 style='width:40.5%;padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>Providing solutions as actuaries, economists, mediators and statisticians.</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td></tr><tr style='height:9.75pt'><td width="15%" style='width:15.18%;padding:.75pt .75pt .75pt .75pt;height:9.75pt'><p class=MsoNormal style='line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>Skype&nbsp; Dennis.Barton.Work</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="25%" style='width:25.32%;padding:.75pt .75pt .75pt .75pt;height:9.75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:maroon;mso-fareast-language:EN-AU'>Telephone +61 8 9225 5899&nbsp; Facsimile + 61 8 9225 5877</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td></tr><tr style='height:9.75pt'><td width="15%" style='width:15.18%;padding:.75pt .75pt .75pt .75pt;height:9.75pt'><p class=MsoNormal style='line-height:105%'><span style='mso-fareast-language:EN-AU'><a href="mailto:[email protected]"><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:black'>[email protected]</span></b></a></span><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="25%" style='width:25.32%;padding:.75pt .75pt .75pt .75pt;height:9.75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><span style='mso-fareast-language:EN-AU'><a href="http://www.actuary.com.au/"><b><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:black'>www.Actuary.com.au</span></b></a></span><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td width="40%" style='width:40.5%;padding:.75pt .75pt .75pt .75pt;height:9.75pt'><p class=MsoNormal align=right style='text-align:right;line-height:105%'><b><span style='font-size:10.0pt;line-height:105%;font-family:"Times New Roman",serif;color:#882124;mso-fareast-language:EN-AU'>ACN 060 885 387</span></b><span style='font-size:12.0pt;line-height:105%;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td></tr><tr><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal style='line-height:105%'><a href="http://au.linkedin.com/pub/dennis-barton/12/459/163"><span style='font-size:7.5pt;line-height:105%;font-family:"Times New Roman",serif;color:black;mso-fareast-language:EN-AU;text-decoration:none'><img border=0 width=79 height=15 id="Picture_x0020_3" src="cid:[email protected]"></span></a><span style='font-size:12.0pt;line-height:105%;font-family:"Times New

Page 16: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

Roman",serif;mso-fareast-language:EN-AU'><o:p></o:p></span></p></td><td colspan=4 style='padding:.75pt .75pt .75pt .75pt'></td></tr><tr><td colspan=5 style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=center style='text-align:center;line-height:105%'><b><span style='color:maroon'>Usual environmental request and legal notices apply.</span></b><o:p></o:p></p></td></tr></table><p class=MsoNormal align=center style='text-align:center'><b><span style='mso-fareast-language:EN-AU'><o:p>&nbsp;</o:p></span></b></p><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>

End of 12 January

11 January2017

The following subroutine works in ABPControl.xlsm, but does not work in Public LaunchEmail.xlsm

Sub testdim()

Dim LEPath$

Dim LEMail As Outlook.MailItem

MsgBox "This works"

End Sub

Both applications have the same tools reference (see below)

The difference is the autofill situations

When, in ABPControl.xlsm, I type “DIM LEMail as O” the autofill presented the following

Page 17: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

In PublicLaunchEmail.xlsm it differs as outlook is not available. What I see is

w

Tools reference comparison

ABPcontrol.xlsm

Public LaunchEmail.xlsm

Page 18: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

Sub testLaunchEmail()

' Material supplied by Richard at Just Answer

'What you need to do is add it as an attachment then reference it to show it in the email

'

'this is the specific code you use

'

'.Attachments.Add "Path to image eg c:\image.jpg", olByValue, 0

'

'Then you use

'

'LEMail.HTMLBody = .HTMLBody & "<br><B>Embedded Image:</B><br>" _ & "<img src='cid:image.jpg'" & "width='500' height='200'><br>" _ & "<br>Best Regards, <br>Sumit</font></span>" .Display

'

'Just be sure to keep the HTML Body img src the same as the name of the attachment.

Page 19: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

' Purpose is to test LaunchEmail subroutine See subroutine for description

Dim TLEAddressee$

Dim TLESubject$

Dim TLEBody$

Dim TLEPath$

Dim TLETop! ' Position in centimetres

Dim TLELeft! ' Position in centimetres

Dim TLEHeight! ' Dimension in centimetres

Dim TLEWidth! ' Dimension in centimetres

' Purpose is to test LaunchEmail subroutine See subroutine for description"

TLEAddressee = "[email protected]"

TLESubject = " Test of launch email with embedded file"

' TLEPath = "C:\Users\dbarton\Pictures\LOGOUBANK.JPG" This is for Barton Consultancy JustAnswer can change this the idea is to be able to insert a Jpg and htm file

TLEPath = "C:\Users\dbarton\Pictures\LOGOUBANK.JPG"

TLETop = 6

TLELeft = 3

TLEWidth = 4

TLEHeight = 5

TLEAddressee = InputBox("Addressee", , TLEAddressee)

TLEPath = InputBox("File to be inserted", , TLEPath)

TLETop = InputBox("Top position centimetres ", , TLETop)

TLELeft = InputBox("Left position centimetres ", , TLELeft)

TLEHeight = InputBox("Height centimetres ", , TLEHeight)

TLEWidth = InputBox("Width centimetres ", , TLEWidth)

Page 20: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

TLEBody = "This is a test of LaunchEmail putting the image" & TLEPath & " at position top, left and dimensions width , height " & TLETop & " " & TLELeft & " " & TLEWidth & " " & TLEHeight & " cms "

Call LaunchEmail(TLEAddressee, "", "", TLESubject, TLEBody, TLEPath, "", TLETop, TLELeft, TLEWidth, TLEHeight, True)

End Sub

' !!!!!!!!!!!!!!!!!!!!!! LAUNCH EMAIL !!!!!!!!!!!!!!!!!!!!!!!

'Subroutine to launch an email

' Source http://chandoo.org/wp/2012/04/23/send-mails-using-excel-vba-and-outlook/

' This requires the reference Microsoft Outlook Object library to be invoked in Tools References

Sub LaunchEmail(LETo$, LECC$, LEBCC$, LESubj$, LEBody$, LEEmbed$, LEAttach$, LETop!, LELeft!, LEWidth!, LEHeight!, LEDisp As Boolean)

' parameters are To, CC,BCC, Subject, Body,File to be embedded in email body _

LEAttach is "" if no file is to be added "1" if the active workbook is to be saved then attached and _

"2" if the active workbook is to be attached without saving if there is no file to be attached, _

LEAttach is "" in the context of VBA for access but can be used in excel _

LEtop, left height and widtth relate to embedded file _

LEDisp =True if message is to display before sending _

Dim LEPath$

Dim LEMail As Outlook.MailItem

Page 21: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

Const letWIPS = 457 ' 457 twips per centimetre

Dim LEPosn% ' Position of end of HTML body stored in LETextWorks

Dim LETextWork$ ' Text working area

Dim LETextInsert$ ' Text to be inserted into HTML Body

Dim LENs As Outlook.Namespace

Set LEApp = New Outlook.Application

Set LENs = LEApp.GetNamespace("MAPI")

LENs.Logon

Set LEMail = LEApp.CreateItem(olMailItem)

If LETo <> "" Then LEMail.to = LETo

If LECC <> "" Then LEMail.CC = LECC

If LEBCC <> "" Then LEMail.BCC = LEBCC

If LESubj <> "" Then LEMail.Subject = LESubj

If LEBody <> "" Then LEMail.Body = LEBody

Debug.Print LEMail.Body

Debug.Print LEMail.HTMLBody

' Subroutine works to here

If LEEmbed = "" Then GoTo LEEmbedDone

.Attachments.Add LEEmbed

'Then you use

'

LEMail.HTMLBody = .HTMLBody & "<br><B>Embedded Image:</B><br>" & "<img src='" & LEEmbed & "'" & "width='500' height='200'><br>" & "<br>Best Regards, <br>Sumit</font></span>"

' This is DB's previous attempt

'LETextWork = LEMail.HTMLBody

' Set up the HTML text to insert the embedded file THIS IS WHERE I NEED JUSTANSWER HELP

'LETextInsert = "<img src='" & LEEmbed & "' height=" & LEHeight * letWIPS & " width=" & LEWidth * letWIPS & " Top=" & LETop * letWIPS & " Left=" & LELeft * letWIPS & ">" & Chr(10)

'LEPosn = InStr(1, LETextWork, "</BODY>") ' Find position of coculsion of body text HTML instruction

Page 22: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

'LETextWork = Left(LETextWork, LEPosn - 1) & LETextInsert & Right(LETextWork, Len(LETextWork) - LEPosn + 1)

'Debug.Print LETextWork

' LEMail.HTMLBody = LETextWork

Debug.Print LEMail.HTMLBody

LEEmbedDone:

'Subroutine works from here

If LEAttach = "" Then GoTo LEAttachDone

LEPath = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

If LEAttach = "1" Then

' MsgBox " Seeking to save and attach active work book"

ActiveWorkbook.Save

LEAttach = LEPath

End If

If LEAttach = "2" Then LEAttach = LEPath

LEMail.Attachments.Add LEAttach

LEAttachDone:

If LEDisp = True Then LEMail.display Else LEMail.Send

End Sub

References screen shot

Page 23: f01.justanswer.comf01.justanswer.com/pNkyRHgG/TestLaunchEmail.docx  · Web view13 January 2107. Getting there… The only problem is that identified on 11 January, namely that

End Sub