Hi. I was wondering if there was a way to send an email without using the Send Object method for a macro. if you use the macro, you will get this warning:
I know in VB .NET you have to import an outlook object or w/e it is and then there were methods that allowed you to edit the To, CC, BCC, subject, etc
I was wondering if there is something similar in VBA to do that.
What i want to do is the following:
1) when user clicks "Send Email" button, it opens up MS Outlook
2) it attaches a report
3) fills out the subject
Thanks!
Aug 1 '11
68 7829 NeoPa 32,556
Recognized Expert Moderator MVP
Jeffrey, did you miss Rabbit's point. The problem is that you have doubled up on the "\" characters. He's correct. That is your problem.
@NeoPa:
oh. I'll try that when i get to work today. Maybe that is the problem. Thanks!
Hopefully it is so this can be closed once and for all :P
NeoPa 32,556
Recognized Expert Moderator MVP
There's no question about it Jeffrey. Even if there are any other problems, that is certainly going to cause your issue all by itself. Your code clearly adds an extra "\" in a few places, which will cause file references to fail.
@NeoPa:
It just puzzles me because the code I sent to my collegue is the exact one i have and his worked. but i'll be sure to double check every line of code when i go to the office.
NeoPa 32,556
Recognized Expert Moderator MVP
I understand Jeffrey.
We can only work with what's in front of us though. I doubt the code you sent to your colleague is exactly as you posted for us (otherwise it wouldn't work), but that isn't a puzzle we need to worry about just now. If that doesn't resolve itself in the wash then we can look at that too, but we'd need a new question and the code your colleague is actually using (rather than what you think you sent to him at some point - however close a match that may or may not turn out to be).
For now though, I'm confident the code you posted has that problem in it (even if there may be others too).
@NeoPa:
yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.
in terms of programs and all, what are usually the requirements to get AcFormatPDF to work?
Microsoft Access 2007
Adobe Acrobat
do you know of anything else?
trying to open up some possibilities and narrow them down when i troubleshoot this. :)
NeoPa 32,556
Recognized Expert Moderator MVP Jeffrey:
yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.
I hope you're referring to what you will do after we finish here. That is not something for this thread. Nor is the question about how to work with PDFs.
For now, you need to fix the code you posted earlier, exactly as suggested by Rabbit, and report on your success.
Anything further can find its way into a new thread if required.
understood :)
thanks again for all this help.
ADezii 8,834
Recognized Expert Expert @NeoPa & Rabbit:
Ironically, the addition of an extra '\' in the OutputFile Argument of the OutputTo() Method, between the lowest level Folder and start of the Filename, will work. The following Code will work with no problems (notice addition of extra '\'): - DoCmd.OutputTo acOutputTable, "tblEmployees", acFormatRTF, "C:\Windows\\Employees.rtf", False
ok im at work now and i fixed the additional "\" but still the same problem.
here's the code: -
Sub sendEmail()
-
-
'Provides the Send Mail automation. Send an E-Mail and Attachment from Access via Outlook
-
Dim oLook As Object
-
Dim oMail As Object
-
Dim olns As Outlook.NameSpace
-
Dim strRecipient As String
-
Dim strBody As String
-
Dim strSubject As String
-
Dim strReportName As String
-
Dim strSource As String
-
Dim strDestination As String
-
Dim title As String
-
-
Set oLook = CreateObject("Outlook.Application")
-
Set olns = oLook.GetNamespace("MAPI")
-
Set oMail = oLook.CreateItem(0)
-
-
'************************** Define your own Values here **************************
-
-
strRecipient = ""
-
strBody = ""
-
strSubject = "Problem Tracking Ticket #: " & [Forms]![User Problem Log]![trouble_no]
-
strReportName = Mid("Email-Single", 7) & " Problem Tracking Ticket # " & [Forms]![User Problem Log]![trouble_no]
-
-
'*********************************************************************************
-
-
strSource = CurrentProject.Path & "\"
-
strDestination = "C:\Windows\Temp\" 'give destination
-
title = "Single Problem Tracking Ticket # "
-
-
If Not FileExists(strDestination) Then
-
MkDir (strDestination)
-
End If
-
If FileExists(strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf") Then
-
Kill strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf"
-
DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
-
Else
-
DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
-
End If
-
With oMail
-
.To = strRecipient
-
.Body = strBody
-
.Subject = strSubject
-
.Attachments.Add strDestination & strReportName & ".pdf", False
-
.Display
-
End With
-
End Sub
NeoPa 32,556
Recognized Expert Moderator MVP
@ADezii
Thanks for the clarification. I should apologise for misleading. I always use Replace() myself to ensure such an anomaly never arises.
@Jeffrey
I'm sure the problem is still the same. Would you mind posting the details again as I don't keep details of all the threads I work on in my RAM, and aging as I am, my HDD is not too hot either. Short of that I would need to search through the thread again, and it's a long thread already.
ah i noticed something else...
see the attached screenshot..
there's no PDF format.
i looked at my colleague's computer and there is PDF... now i'm 100% sure that is the problem.
NeoPa 32,556
Recognized Expert Moderator MVP
Did you not say you were developing on a 2007 system? If not, then acOutputPDF was introduced in 2007 so that would explain the omission. If so, then I can only guess that support for PDF is an optional inclusion and you may need to reinstall the software making sure that PDF support is included.
@NeoPa:
Yeah the database was recently converted from 2000 (or 2002, i forget) to 2007. doubt it has anything to do with the fact that he's using windows 7 and i'm still on XP. maybe ill try to reinstall access 2007 and adobe pdf.
omg finally i fixed it!
i reinstalled MS office and adobe acrobat... still the same problem.. so i figured i'd google it and see if anything came up.
Turns out that I was missing an addin for 2007. http://support.microsoft.com/kb/934833
so i downloaded the Microsoft Save as PDF or XPS addin, installed it and now it works perfectly :)
NeoPa 32,556
Recognized Expert Moderator MVP
So not only is 2007 required, but a separate download is also required. Sorry for the bum info Jeffrey. I had no idea that PDF wasn't available as standard in 2007 (I still only use up to 2003 personally). Well done for clearing that up though
@NeoPa: yeah i didn't know either lol.
So I guess this would be a good reference for those who want to try the same and gets to this problem as well :)
NeoPa 32,556
Recognized Expert Moderator MVP
I guess so. It can't hurt :-)
In my database I do something very similar. Works GREAT!
Something like this: - DoCmd.OutputTo acOutputReport, "rptCrewAuthorization", acFormatSNP, outFileName(0), False
- GenerateEmail "asdf@asdf.com", "sdfg@sdfg.com;dfgh@dfgh.com", "fghj@fghj.com;ghjk@ghjk.com", ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " - Starting " & Forms!frmCrewAuthorization!AuthDate.Value, Forms!frmCrewAuthorization!Name.Value & "'s Crew" & vbCrLf & vbCrLf, outFileName, False
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dave |
last post by:
hi guys
I m trying to execute few lines code tht i have copies
from microsoft tech script centre.
basically its to send email without using any smtp
service. u can find the code snippet from...
|
by: jdph40 |
last post by:
I'm using Access 97. In the OnClick event of a button I have the code
below. I looks at txtEmail and sends an e-mail message without
further action from the user (user does not have to click Send...
|
by: Ronny Sigo |
last post by:
Hello all,
Can anyone tell me how to prevent my mailprog to display the mail, and just
send it ?
The code I use is below
Any help appreciated ..
Thanks
Ronny Sigo
Private Declare Function...
|
by: Mike |
last post by:
In VB6 I could send email via Outlook without using SMTP, Is it possible to
do the same in .NET and if so is there any examples of doing this?
|
by: CLEAR-RCIC |
last post by:
I want to send an email from our Intranet site to myself whenever an error
happens. Our manager will not let us install SMTP on the web server. Is it
possible to send email programatically...
| |
by: ErwinF |
last post by:
Hi there,
I would like to know the following:
How to send send email attachments using WebDAV in VB .NET? Sample code please...................
Thanks for your help.
|
by: Siv |
last post by:
Hi,
A little while ago I wrote a small program that allowed the user to view
products from a database. The database holds the details of the products
which can be viewed via a form and...
|
by: win |
last post by:
Please answer me.
Thanks.
|
by: Boki |
last post by:
Hi All,
I want to create a program that auto send out email ( not email bomb )
to myself.
I tried the MAPI, but it will show a notiifcation message, user need
to confirm that.
My target is...
|
by: phill86 |
last post by:
Hi
I am using the following code to send an email from access via outlook automatically
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, "User", , , , , False
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
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,...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |