473,670 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending Email Attachment, wrong Outlook Version

I have some code, from this group (many thanks) that sends an
attachment to an email.

The following:

Dim objNewMail As Outlook.MailIte m
Dim golApp As Outlook.Applica tion
Dim initializeOutlo ok As Boolean

requires Microsoft Outlook xx Object Library in the references.

My problem is that I have Oulook 2003 (xx = 11), the PC's that I want
to run it on has Outlook 2000 or 97 (!), and more of a problem only
Access 2000 runtime.

When I load up the database on their PC because it can't find the
reference it's looking for (Outlook 11) I get a runtime error, and
Access closes. I can't change the reference to their version of
Outlook as they, as mentioned, only have the runtime.

So for now I've removed the code / reference.

My question is "How can I get around this?" I thought I was being very
clever, now I'm stumped. I need to have code that will email a file,
that is generated within Access, as an attachment.

I'd really like some generic code that would use whatever email program
they have, I guess.

Any ideas?

Thank you,

Jon

Jan 25 '06 #1
5 2868
J-P-W wrote in message
<11************ **********@o13g 2000cwo.googleg roups.com> :
I have some code, from this group (many thanks) that sends an
attachment to an email.

The following:

Dim objNewMail As Outlook.MailIte m
Dim golApp As Outlook.Applica tion
Dim initializeOutlo ok As Boolean

requires Microsoft Outlook xx Object Library in the references.

My problem is that I have Oulook 2003 (xx = 11), the PC's that I want
to run it on has Outlook 2000 or 97 (!), and more of a problem only
Access 2000 runtime.

When I load up the database on their PC because it can't find the
reference it's looking for (Outlook 11) I get a runtime error, and
Access closes. I can't change the reference to their version of
Outlook as they, as mentioned, only have the runtime.

So for now I've removed the code / reference.

My question is "How can I get around this?" I thought I was being very
clever, now I'm stumped. I need to have code that will email a file,
that is generated within Access, as an attachment.

I'd really like some generic code that would use whatever email program
they have, I guess.

Any ideas?

Thank you,

Jon


Try late binding.

It means you remove the references, and declare like this

Dim objNewMail As object 'Outlook.MailIt em
Dim golApp As object 'Outlook.Applic ation

In stead of using the New keyword when instantiating, you use

set golapp = createobject("o utlook.applicat ion")

- or do a combination/test for existing open app through the getobject
function

Note - Outlooks specific constants must be replaced. (they are often
prefixed with "ol") For instance a line like this

set objNewMail = golApp.createit em(olMailItem)

should be replaced with something like

set objNewMail = golApp.createit em(0)

--
Roy-Vidar
Jan 25 '06 #2
Great, thanks I'll give that a go!

Regards, Jon

Jan 25 '06 #3
Outlook is a gnarly program; MS recommends the use of CDO to send
e-mail

This sample code will send a report as html. It should run in
Northwinds.
If you take a little time and study it, you can probably modify it to
meet your needs.
It has no magic to guess your smtp server, or other parameter.
If you write it without specifying many of the properties it will just
fall back on Outlook Express default account settings, if these exist.

It should work with Windows 2000 or Windows XP.

Option Explicit

Public Sub SendReportAsHTM L( _
ByVal ReportName As String, _
ByVal SMTPServer As String, _
ByVal SendUserName As String, _
ByVal SendPassword As String, _
ByVal SendEmailAddres s As String, _
ByVal Subject As String, _
ByVal Recipients As String, _
Optional ByVal NumberofPagesAl lowed As Long = 10)

Dim Buffer As String
Dim Position As Long
Dim FileNumber As Integer
Dim HTML As String
Dim HTMLFullPath As String
Dim iCfg As Object
Dim iMsg As Object
Dim Skelton As String
Dim TempDirectory As String
Dim Truncate As Long

Set iCfg = CreateObject("C DO.Configuratio n")
Set iMsg = CreateObject("C DO.Message")

TempDirectory = Environ$("temp" )
If Len(TempDirecto ry) = 0 Then TempDirectory = CurDir$()
TempDirectory = TempDirectory & "\"
Skelton = Format(Now(), "mmmddyyyyhhnns s")
HTMLFullPath = TempDirectory & Skelton & ".html"

DoCmd.OutputTo acOutputReport, ReportName, acFormatHTML, HTMLFullPath

HTMLFullPath = Dir$(TempDirect ory & Skelton & "*.html")
While Len(HTMLFullPat h) <> 0 And NumberofPagesAl lowed <> 0
HTMLFullPath = TempDirectory & HTMLFullPath
FileNumber = FreeFile()
Open HTMLFullPath For Binary As #FileNumber
Buffer = String(LOF(File Number), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber
Position = InStr(Buffer, "</TABLE>")
While Position <> 0
Truncate = Position
Position = InStr(Truncate + 1, Buffer, "</TABLE>")
Wend
HTML = HTML & Left(Buffer, Truncate + 7)
HTML = HTML & "<hr>"
Kill HTMLFullPath
HTMLFullPath = Dir$()
NumberofPagesAl lowed = NumberofPagesAl lowed - 1
Wend

If Len(HTMLFullPat h) <> 0 And NumberofPagesAl lowed = 0 Then _
HTML = HTML & "<br><b>Par tial Report: Additional Pages not Shown"

With iCfg.Fields
..Item("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" )
= 25
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") =
SMTPServer
..Item("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e")
= 1
..Item("http://schemas.microso ft.com/cdo/configuration/sendusername") =
SendUserName
..Item("http://schemas.microso ft.com/cdo/configuration/sendpassword") =
SendPassword
..Item("http://schemas.microso ft.com/cdo/configuration/sendemailaddres s")
= SendEmailAddres s
..Update
End With
With iMsg
..Configuration = iCfg
..Subject = Subject
..To = Recipients
..HTMLBody = HTML
..Send
End With

SendReportAsHTM LExit:
Close
Set iMsg = Nothing
Set iCfg = Nothing
Exit Sub

SendReportAsHTM LErr:
With Err
MsgBox .Description, vbCritical, "Error " & .Number
End With
Resume SendReportAsHTM LExit

End Sub

Private Sub TestSendReportA sHTML()
SendReportAsHTM L "Products By Category", "mail.yoursmtps erver.com",
"youremail.com" , "thepasswor d", "thesender" , "Testing
SendReportAsHTM L", "th*********@hi sherdomain.com"
End Sub

Jan 25 '06 #4
Hi Lyle,
although this may be very useful for another project, I guess not in
this case as the clients send all mail through an exchange server, and
don't even know the relevant passwords, that for the IT bods to know!!!
Regards
Jon

Jan 26 '06 #5
Lyle sorry, I will read the reply better next time... now I note "If
you write it without specifying many of the properties it will just
fall back on Outlook Express default account settings, if these exist."
Many thanks
Jon :{

Jan 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4301
by: Sven Templin | last post by:
Hello all, our configuration is as following described: - OS: Windows 2000 - Apache server 1.3 - Php 3.8 - MS outlook client 2000 _and_ no SMTP server available in the whole intranet.
2
457
by: Tom Dauria | last post by:
I have a Access database application that sends email through Outlook. A few years ago we started having a problem where it would ask for each and every email being sent whether you want to give access to your email addresses in outlook and then something about sending mail on your behalf. Anyway we purchased software called Outlook Redemption. The thing is we are having some problem with that software now and I had heard that with...
4
2242
by: Robert McNally | last post by:
Hello, I'm currently learning c# and have been trying to write a simple program with sockets. The problem is i'm trying to send an email with an attachment, (which is the program itself) by using base64. When i run it it sends the email ok, but and attchment doesn't work i get an error when i run it. The attchment seems to be bigger (20k) then the orginal (16k) i've included the source which i have been using. Can someone tell me what...
6
2740
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
1
10414
by: handokowidjaja | last post by:
Hi All, Several weeks ago i started a topic with the same subject, however the solutions provided was for using MS Outlook (fullblown version). I finally found something that works directly with Outlook Express, however i dont know how to attach any document using the below code. If anybody knows how to do it, please help me to modify the below code and provide some sample on how to use it. Thanks in advance.
6
11293
by: Rushwire | last post by:
Does anybody know how to send a meeting request using an ics/vcs (VCalendar) attachment from an asp.net page. I don't want my users to have to double click on the attachment but rather that it is simply recognised automatically as a meeting request. The article below shows an example of very close to what I am trying to do. The difference being that I want the email to be sent as a meeting request not as an attached ics file.
2
3663
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to...
7
8555
by: Paridevi | last post by:
Hai , i want to send email in .Net Using OutLook Express,My Project is Web Application using vb.Net 2003 with SQL Server 2000.I have searched a lot in Google, but ican't get any details. Pls its urgent for me. Can any one give me any idea about this. Thanks in advance Pari
2
4284
by: Erik Witkop | last post by:
So I have been trying to get this to work all day. I can't get a local file on my web server to attach to an email. Right now I have it printing out in the body of the email. Please help me with any thouhgts on how to get it in as an attachment. CODE: <?php ini_set(SMTP, "172.18.1.65");
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.