now for the bigger problam :)
I know you pepole hate using OE for sending emails, but its user friendly and its needed in this case...
I found on this forum, a code that sends email using OE with attachments.
it works, but with two problams... first, its directly sends the email, without opening the OE "editing mode" of the email, like when you use the DoCmd.SendObject.
this is the smaller problams though...
the bigger problam which I think is connected to the first one, is that when it send the email it also neutralize access completely untill the email is sent. and if I attach a big file (which will be always in my db case...) you can't continue working on the db... : \
maybe I need a completly diffrent code, but I'll paste what I'm trying anyway, maybe it will help someone else :)
on a module: -
Option Compare Database
-
Option Explicit
-
-
-
Private Type MAPIRecip
-
Reserved As Long
-
RecipClass As Long
-
Name As String
-
Address As String
-
EIDSize As Long
-
EntryID As String
-
End Type
-
-
Private Type MAPIFileTag
-
Reserved As Long
-
TagLength As Long
-
Tag() As Byte
-
EncodingLength As Long
-
Encoding() As Byte
-
End Type
-
-
Private Type MAPIFile
-
Reserved As Long
-
Flags As Long
-
Position As Long
-
PathName As String
-
FileName As String
-
FileType As Long
-
End Type
-
-
Private Type MAPIMessage
-
Reserved As Long
-
Subject As String
-
NoteText As String
-
MessageType As String
-
DateReceived As String
-
ConversationID As String
-
Originator As Long
-
Flags As Long
-
RecipCount As Long
-
Recipients As Long
-
FileCount As Long
-
Files As Long
-
End Type
-
-
Private Declare Function MAPISendMail Lib "c:\program files\outlook express\msoe.dll" (ByVal Session As Long, ByVal UIParam As Long, ByRef message As MAPIMessage, ByVal Flags As Long, ByVal Reserved As Long) As Long
-
Private Const MAPI_E_NO_LIBRARY = 999
-
Private Const MAPI_E_INVALID_PARAMETER = 998
-
-
Private Const MAPI_ORIG = 0
-
Private Const MAPI_TO = 1
-
Private Const MAPI_CC = 2
-
Private Const MAPI_BCC = 3
-
-
Private Const MAPI_UNREAD = 1
-
Private Const MAPI_RECEIPT_REQUESTED = 2
-
Private Const MAPI_SENT = 4
-
-
Private Const MAPI_LOGON_UI = &H1
-
Private Const MAPI_NEW_SESSION = &H2
-
Private Const MAPI_DIALOG = &H8
-
Private Const MAPI_UNREAD_ONLY = &H20
-
Private Const MAPI_ENVELOPE_ONLY = &H40
-
Private Const MAPI_PEEK = &H80
-
Private Const MAPI_GUARANTEE_FIFO = &H100
-
Private Const MAPI_BODY_AS_FILE = &H200
-
Private Const MAPI_AB_NOMODIFY = &H400
-
Private Const MAPI_SUPPRESS_ATTAch = &H800
-
Private Const MAPI_FORCE_DOWNLOAD = &H1000
-
-
Private Const MAPI_OLE = &H1
-
Private Const MAPI_OLE_STATIC = &H2
-
-
-
Dim mAf() As MAPIFile
-
Dim mAr() As MAPIRecip
-
Dim lAr As Long
-
Dim lAf As Long
-
Dim mM As MAPIMessage
-
Dim aErrors(0 To 26) As String
-
-
Public Sub Class_Initialize()
-
aErrors(0) = "Success"
-
aErrors(1) = "User Abort"
-
aErrors(2) = "Failure"
-
aErrors(3) = "LogIn Failure"
-
aErrors(4) = "Disk Full"
-
aErrors(5) = "Insufficient Memory"
-
aErrors(6) = "Block Too Small"
-
aErrors(8) = "Too Many Sessions"
-
aErrors(9) = "Too Many Files"
-
aErrors(10) = "Too Many Recipients"
-
aErrors(11) = "Attachment No Found"
-
aErrors(12) = "Attachment Open Failure"
-
aErrors(13) = "Attachment Write Failure"
-
aErrors(14) = "Unknown Recipient"
-
aErrors(15) = "Bad Recipient"
-
aErrors(16) = "No Messages"
-
aErrors(17) = "Invalid Message"
-
aErrors(18) = "Text Too Large"
-
aErrors(19) = "Invalid Session"
-
aErrors(20) = "Type Not Suppported"
-
aErrors(21) = "Ambiguous Recipient"
-
aErrors(22) = "Message in Use"
-
aErrors(23) = "Network Failure"
-
aErrors(24) = "Invalid Edit Fields"
-
aErrors(25) = "Invalid Recipient"
-
aErrors(26) = "Not Supported"
-
End Sub
-
-
Public Sub BCCAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_BCC, , strAddress
-
End Sub
-
-
Public Sub BCCNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_BCC, strName
-
End Sub
-
-
Public Sub CCAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_CC, , strAddress
-
End Sub
-
-
Public Sub CCNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_CC, strName
-
End Sub
-
-
Public Sub MessageIs(ByVal strNoteText As String)
-
mM.NoteText = strNoteText
-
End Sub
-
-
Public Sub SubjectIs(ByVal strSubject As String)
-
mM.Subject = strSubject
-
End Sub
-
-
Public Sub ToAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_TO, , strAddress
-
End Sub
-
-
Public Sub ToNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_TO, strName
-
End Sub
-
-
Public Sub FileAdd(ByVal strPathName As String)
-
Dim f As MAPIFile
-
With f
-
.PathName = StrConv(strPathName, vbFromUnicode)
-
End With
-
ReDim Preserve mAf(lAf)
-
mAf(lAf) = f
-
lAf = lAf + 1
-
End Sub
-
-
Public Sub Send()
-
Dim r As Long
-
With mM
-
If lAf > 0 Then
-
.FileCount = lAf
-
.Files = VarPtr(mAf(0))
-
End If
-
If lAr > 0 Then
-
.RecipCount = lAr
-
.Recipients = VarPtr(mAr(0))
-
r = MAPISendMail(0, 0, mM, 0, 0)
-
If r <> 0 Then MsgBox aErrors(r)
-
End If
-
End With
-
End Sub
-
-
Private Sub RecipientAdd(ByVal lngType As Long, Optional ByVal strName As String, Optional ByVal strAddress As String)
-
Dim r As MAPIRecip
-
r.RecipClass = lngType
-
If strName <> "" Then r.Name = StrConv(strName, vbFromUnicode)
-
If strAddress <> "" Then r.Address = StrConv(strAddress, vbFromUnicode)
-
ReDim Preserve mAr(lAr)
-
mAr(lAr) = r
-
lAr = lAr + 1
-
End Sub
-
-
1 2701
now for the bigger problam :)
I know you pepole hate using OE for sending emails, but its user friendly and its needed in this case...
I found on this forum, a code that sends email using OE with attachments.
it works, but with two problams... first, its directly sends the email, without opening the OE "editing mode" of the email, like when you use the DoCmd.SendObject.
this is the smaller problams though...
the bigger problam which I think is connected to the first one, is that when it send the email it also neutralize access completely untill the email is sent. and if I attach a big file (which will be always in my db case...) you can't continue working on the db... : \
maybe I need a completly diffrent code, but I'll paste what I'm trying anyway, maybe it will help someone else :)
on a module: -
Option Compare Database
-
Option Explicit
-
-
-
Private Type MAPIRecip
-
Reserved As Long
-
RecipClass As Long
-
Name As String
-
Address As String
-
EIDSize As Long
-
EntryID As String
-
End Type
-
-
Private Type MAPIFileTag
-
Reserved As Long
-
TagLength As Long
-
Tag() As Byte
-
EncodingLength As Long
-
Encoding() As Byte
-
End Type
-
-
Private Type MAPIFile
-
Reserved As Long
-
Flags As Long
-
Position As Long
-
PathName As String
-
FileName As String
-
FileType As Long
-
End Type
-
-
Private Type MAPIMessage
-
Reserved As Long
-
Subject As String
-
NoteText As String
-
MessageType As String
-
DateReceived As String
-
ConversationID As String
-
Originator As Long
-
Flags As Long
-
RecipCount As Long
-
Recipients As Long
-
FileCount As Long
-
Files As Long
-
End Type
-
-
Private Declare Function MAPISendMail Lib "c:\program files\outlook express\msoe.dll" (ByVal Session As Long, ByVal UIParam As Long, ByRef message As MAPIMessage, ByVal Flags As Long, ByVal Reserved As Long) As Long
-
Private Const MAPI_E_NO_LIBRARY = 999
-
Private Const MAPI_E_INVALID_PARAMETER = 998
-
-
Private Const MAPI_ORIG = 0
-
Private Const MAPI_TO = 1
-
Private Const MAPI_CC = 2
-
Private Const MAPI_BCC = 3
-
-
Private Const MAPI_UNREAD = 1
-
Private Const MAPI_RECEIPT_REQUESTED = 2
-
Private Const MAPI_SENT = 4
-
-
Private Const MAPI_LOGON_UI = &H1
-
Private Const MAPI_NEW_SESSION = &H2
-
Private Const MAPI_DIALOG = &H8
-
Private Const MAPI_UNREAD_ONLY = &H20
-
Private Const MAPI_ENVELOPE_ONLY = &H40
-
Private Const MAPI_PEEK = &H80
-
Private Const MAPI_GUARANTEE_FIFO = &H100
-
Private Const MAPI_BODY_AS_FILE = &H200
-
Private Const MAPI_AB_NOMODIFY = &H400
-
Private Const MAPI_SUPPRESS_ATTAch = &H800
-
Private Const MAPI_FORCE_DOWNLOAD = &H1000
-
-
Private Const MAPI_OLE = &H1
-
Private Const MAPI_OLE_STATIC = &H2
-
-
-
Dim mAf() As MAPIFile
-
Dim mAr() As MAPIRecip
-
Dim lAr As Long
-
Dim lAf As Long
-
Dim mM As MAPIMessage
-
Dim aErrors(0 To 26) As String
-
-
Public Sub Class_Initialize()
-
aErrors(0) = "Success"
-
aErrors(1) = "User Abort"
-
aErrors(2) = "Failure"
-
aErrors(3) = "LogIn Failure"
-
aErrors(4) = "Disk Full"
-
aErrors(5) = "Insufficient Memory"
-
aErrors(6) = "Block Too Small"
-
aErrors(8) = "Too Many Sessions"
-
aErrors(9) = "Too Many Files"
-
aErrors(10) = "Too Many Recipients"
-
aErrors(11) = "Attachment No Found"
-
aErrors(12) = "Attachment Open Failure"
-
aErrors(13) = "Attachment Write Failure"
-
aErrors(14) = "Unknown Recipient"
-
aErrors(15) = "Bad Recipient"
-
aErrors(16) = "No Messages"
-
aErrors(17) = "Invalid Message"
-
aErrors(18) = "Text Too Large"
-
aErrors(19) = "Invalid Session"
-
aErrors(20) = "Type Not Suppported"
-
aErrors(21) = "Ambiguous Recipient"
-
aErrors(22) = "Message in Use"
-
aErrors(23) = "Network Failure"
-
aErrors(24) = "Invalid Edit Fields"
-
aErrors(25) = "Invalid Recipient"
-
aErrors(26) = "Not Supported"
-
End Sub
-
-
Public Sub BCCAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_BCC, , strAddress
-
End Sub
-
-
Public Sub BCCNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_BCC, strName
-
End Sub
-
-
Public Sub CCAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_CC, , strAddress
-
End Sub
-
-
Public Sub CCNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_CC, strName
-
End Sub
-
-
Public Sub MessageIs(ByVal strNoteText As String)
-
mM.NoteText = strNoteText
-
End Sub
-
-
Public Sub SubjectIs(ByVal strSubject As String)
-
mM.Subject = strSubject
-
End Sub
-
-
Public Sub ToAddressAdd(ByVal strAddress As String)
-
RecipientAdd MAPI_TO, , strAddress
-
End Sub
-
-
Public Sub ToNameAdd(ByVal strName As String)
-
RecipientAdd MAPI_TO, strName
-
End Sub
-
-
Public Sub FileAdd(ByVal strPathName As String)
-
Dim f As MAPIFile
-
With f
-
.PathName = StrConv(strPathName, vbFromUnicode)
-
End With
-
ReDim Preserve mAf(lAf)
-
mAf(lAf) = f
-
lAf = lAf + 1
-
End Sub
-
-
Public Sub Send()
-
Dim r As Long
-
With mM
-
If lAf > 0 Then
-
.FileCount = lAf
-
.Files = VarPtr(mAf(0))
-
End If
-
If lAr > 0 Then
-
.RecipCount = lAr
-
.Recipients = VarPtr(mAr(0))
-
r = MAPISendMail(0, 0, mM, 0, 0)
-
If r <> 0 Then MsgBox aErrors(r)
-
End If
-
End With
-
End Sub
-
-
Private Sub RecipientAdd(ByVal lngType As Long, Optional ByVal strName As String, Optional ByVal strAddress As String)
-
Dim r As MAPIRecip
-
r.RecipClass = lngType
-
If strName <> "" Then r.Name = StrConv(strName, vbFromUnicode)
-
If strAddress <> "" Then r.Address = StrConv(strAddress, vbFromUnicode)
-
ReDim Preserve mAr(lAr)
-
mAr(lAr) = r
-
lAr = lAr + 1
-
End Sub
-
-
It could be the nature of the code that it is executed synchronously, meaning all other processes are suspended until current code completion. Sign in to post your reply or Sign up for a free account.
Similar topics
by: ian |
last post by:
Hi,
I'm a newbie (oh no I can here you say.... another one...)
How can I get Python to send emails using the default windows email
client (eg outlook express)?
I thought I could just do the...
|
by: David Burson |
last post by:
Hi,
I have a VB.NET windows app that needs to automatically send a simple text
email when my users run a new version of the app for the first time. I
thought this would be simple, but after...
|
by: Ronny Sigo |
last post by:
Hello all,
I a struggling for a few days now to find a way to send automated mail. I
succeeded except that MS Outlook always gives me those 2 stupid warnings
that 1) a "program tries to get...
|
by: Jay McGrath |
last post by:
Help - trying to send a simple text email with with as little user
intervention.
I am trying to create a button in my Access application that will
automatically send a simple text email. It...
|
by: Marcus |
last post by:
I tried DoCmd.SendObject on Access 2002 with Win2000 and no worries, it
works. But, DoCmd.SendObject does not work on Access 2002 using WinXP.
Wondering if there is a work around?
Marcus...
|
by: roni |
last post by:
i dont like to use ocx controlx.
is there new dll for vb.net that do the job ? or newer code, to send email
throught outlook express.
|
by: cj |
last post by:
How can I get a button in VB to send the contents of a text box via
email in a manner similar to the "Send To\Mail Recipient" functionality
that you can select via right clicking a file in Windows...
|
by: ManningFan |
last post by:
I built a nifty little SPAM killer with Access linking into Outlook
while I was at work the other day (boring day, loads of time to
kill...) but now I'd like to use it at home where we use Outlook...
|
by: Bibin |
last post by:
I want to send email via Outlook Express and not by Outlook in VB.NET (windows application). I also want to attach files with the email. The mail (in Outlook Express) needs to be displayed before...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |