473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Send email with outlook express 'editing mode'

59
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:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.  
  5. Private Type MAPIRecip
  6. Reserved As Long
  7. RecipClass As Long
  8. Name As String
  9. Address As String
  10. EIDSize As Long
  11. EntryID As String
  12. End Type
  13.  
  14. Private Type MAPIFileTag
  15. Reserved As Long
  16. TagLength As Long
  17. Tag() As Byte
  18. EncodingLength As Long
  19. Encoding() As Byte
  20. End Type
  21.  
  22. Private Type MAPIFile
  23. Reserved As Long
  24. Flags As Long
  25. Position As Long
  26. PathName As String
  27. FileName As String
  28. FileType As Long
  29. End Type
  30.  
  31. Private Type MAPIMessage
  32. Reserved As Long
  33. Subject As String
  34. NoteText As String
  35. MessageType As String
  36. DateReceived As String
  37. ConversationID As String
  38. Originator As Long
  39. Flags As Long
  40. RecipCount As Long
  41. Recipients As Long
  42. FileCount As Long
  43. Files As Long
  44. End Type
  45.  
  46. 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
  47. Private Const MAPI_E_NO_LIBRARY = 999
  48. Private Const MAPI_E_INVALID_PARAMETER = 998
  49.  
  50. Private Const MAPI_ORIG = 0
  51. Private Const MAPI_TO = 1
  52. Private Const MAPI_CC = 2
  53. Private Const MAPI_BCC = 3
  54.  
  55. Private Const MAPI_UNREAD = 1
  56. Private Const MAPI_RECEIPT_REQUESTED = 2
  57. Private Const MAPI_SENT = 4
  58.  
  59. Private Const MAPI_LOGON_UI = &H1
  60. Private Const MAPI_NEW_SESSION = &H2
  61. Private Const MAPI_DIALOG = &H8
  62. Private Const MAPI_UNREAD_ONLY = &H20
  63. Private Const MAPI_ENVELOPE_ONLY = &H40
  64. Private Const MAPI_PEEK = &H80
  65. Private Const MAPI_GUARANTEE_FIFO = &H100
  66. Private Const MAPI_BODY_AS_FILE = &H200
  67. Private Const MAPI_AB_NOMODIFY = &H400
  68. Private Const MAPI_SUPPRESS_ATTAch = &H800
  69. Private Const MAPI_FORCE_DOWNLOAD = &H1000
  70.  
  71. Private Const MAPI_OLE = &H1
  72. Private Const MAPI_OLE_STATIC = &H2
  73.  
  74.  
  75. Dim mAf() As MAPIFile
  76. Dim mAr() As MAPIRecip
  77. Dim lAr As Long
  78. Dim lAf As Long
  79. Dim mM As MAPIMessage
  80. Dim aErrors(0 To 26) As String
  81.  
  82. Public Sub Class_Initialize()
  83. aErrors(0) = "Success"
  84. aErrors(1) = "User Abort"
  85. aErrors(2) = "Failure"
  86. aErrors(3) = "LogIn Failure"
  87. aErrors(4) = "Disk Full"
  88. aErrors(5) = "Insufficient Memory"
  89. aErrors(6) = "Block Too Small"
  90. aErrors(8) = "Too Many Sessions"
  91. aErrors(9) = "Too Many Files"
  92. aErrors(10) = "Too Many Recipients"
  93. aErrors(11) = "Attachment No Found"
  94. aErrors(12) = "Attachment Open Failure"
  95. aErrors(13) = "Attachment Write Failure"
  96. aErrors(14) = "Unknown Recipient"
  97. aErrors(15) = "Bad Recipient"
  98. aErrors(16) = "No Messages"
  99. aErrors(17) = "Invalid Message"
  100. aErrors(18) = "Text Too Large"
  101. aErrors(19) = "Invalid Session"
  102. aErrors(20) = "Type Not Suppported"
  103. aErrors(21) = "Ambiguous Recipient"
  104. aErrors(22) = "Message in Use"
  105. aErrors(23) = "Network Failure"
  106. aErrors(24) = "Invalid Edit Fields"
  107. aErrors(25) = "Invalid Recipient"
  108. aErrors(26) = "Not Supported"
  109. End Sub
  110.  
  111. Public Sub BCCAddressAdd(ByVal strAddress As String)
  112.     RecipientAdd MAPI_BCC, , strAddress
  113. End Sub
  114.  
  115. Public Sub BCCNameAdd(ByVal strName As String)
  116.     RecipientAdd MAPI_BCC, strName
  117. End Sub
  118.  
  119. Public Sub CCAddressAdd(ByVal strAddress As String)
  120.     RecipientAdd MAPI_CC, , strAddress
  121. End Sub
  122.  
  123. Public Sub CCNameAdd(ByVal strName As String)
  124.     RecipientAdd MAPI_CC, strName
  125. End Sub
  126.  
  127. Public Sub MessageIs(ByVal strNoteText As String)
  128.     mM.NoteText = strNoteText
  129. End Sub
  130.  
  131. Public Sub SubjectIs(ByVal strSubject As String)
  132.     mM.Subject = strSubject
  133. End Sub
  134.  
  135. Public Sub ToAddressAdd(ByVal strAddress As String)
  136.     RecipientAdd MAPI_TO, , strAddress
  137. End Sub
  138.  
  139. Public Sub ToNameAdd(ByVal strName As String)
  140.     RecipientAdd MAPI_TO, strName
  141. End Sub
  142.  
  143. Public Sub FileAdd(ByVal strPathName As String)
  144.     Dim f As MAPIFile
  145. With f
  146.     .PathName = StrConv(strPathName, vbFromUnicode)
  147. End With
  148. ReDim Preserve mAf(lAf)
  149. mAf(lAf) = f
  150. lAf = lAf + 1
  151. End Sub
  152.  
  153. Public Sub Send()
  154. Dim r As Long
  155. With mM
  156.     If lAf > 0 Then
  157.         .FileCount = lAf
  158.         .Files = VarPtr(mAf(0))
  159.     End If
  160.     If lAr > 0 Then
  161.         .RecipCount = lAr
  162.         .Recipients = VarPtr(mAr(0))
  163.         r = MAPISendMail(0, 0, mM, 0, 0)
  164.         If r <> 0 Then MsgBox aErrors(r)
  165.     End If
  166. End With
  167. End Sub
  168.  
  169. Private Sub RecipientAdd(ByVal lngType As Long, Optional ByVal strName As String, Optional ByVal strAddress As String)
  170. Dim r As MAPIRecip
  171. r.RecipClass = lngType
  172. If strName <> "" Then r.Name = StrConv(strName, vbFromUnicode)
  173. If strAddress <> "" Then r.Address = StrConv(strAddress, vbFromUnicode)
  174. ReDim Preserve mAr(lAr)
  175. mAr(lAr) = r
  176. lAr = lAr + 1
  177. End Sub
  178.  
  179.  
Sep 8 '07 #1
1 2701
ADezii
8,834 Expert 8TB
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:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.  
  5. Private Type MAPIRecip
  6. Reserved As Long
  7. RecipClass As Long
  8. Name As String
  9. Address As String
  10. EIDSize As Long
  11. EntryID As String
  12. End Type
  13.  
  14. Private Type MAPIFileTag
  15. Reserved As Long
  16. TagLength As Long
  17. Tag() As Byte
  18. EncodingLength As Long
  19. Encoding() As Byte
  20. End Type
  21.  
  22. Private Type MAPIFile
  23. Reserved As Long
  24. Flags As Long
  25. Position As Long
  26. PathName As String
  27. FileName As String
  28. FileType As Long
  29. End Type
  30.  
  31. Private Type MAPIMessage
  32. Reserved As Long
  33. Subject As String
  34. NoteText As String
  35. MessageType As String
  36. DateReceived As String
  37. ConversationID As String
  38. Originator As Long
  39. Flags As Long
  40. RecipCount As Long
  41. Recipients As Long
  42. FileCount As Long
  43. Files As Long
  44. End Type
  45.  
  46. 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
  47. Private Const MAPI_E_NO_LIBRARY = 999
  48. Private Const MAPI_E_INVALID_PARAMETER = 998
  49.  
  50. Private Const MAPI_ORIG = 0
  51. Private Const MAPI_TO = 1
  52. Private Const MAPI_CC = 2
  53. Private Const MAPI_BCC = 3
  54.  
  55. Private Const MAPI_UNREAD = 1
  56. Private Const MAPI_RECEIPT_REQUESTED = 2
  57. Private Const MAPI_SENT = 4
  58.  
  59. Private Const MAPI_LOGON_UI = &H1
  60. Private Const MAPI_NEW_SESSION = &H2
  61. Private Const MAPI_DIALOG = &H8
  62. Private Const MAPI_UNREAD_ONLY = &H20
  63. Private Const MAPI_ENVELOPE_ONLY = &H40
  64. Private Const MAPI_PEEK = &H80
  65. Private Const MAPI_GUARANTEE_FIFO = &H100
  66. Private Const MAPI_BODY_AS_FILE = &H200
  67. Private Const MAPI_AB_NOMODIFY = &H400
  68. Private Const MAPI_SUPPRESS_ATTAch = &H800
  69. Private Const MAPI_FORCE_DOWNLOAD = &H1000
  70.  
  71. Private Const MAPI_OLE = &H1
  72. Private Const MAPI_OLE_STATIC = &H2
  73.  
  74.  
  75. Dim mAf() As MAPIFile
  76. Dim mAr() As MAPIRecip
  77. Dim lAr As Long
  78. Dim lAf As Long
  79. Dim mM As MAPIMessage
  80. Dim aErrors(0 To 26) As String
  81.  
  82. Public Sub Class_Initialize()
  83. aErrors(0) = "Success"
  84. aErrors(1) = "User Abort"
  85. aErrors(2) = "Failure"
  86. aErrors(3) = "LogIn Failure"
  87. aErrors(4) = "Disk Full"
  88. aErrors(5) = "Insufficient Memory"
  89. aErrors(6) = "Block Too Small"
  90. aErrors(8) = "Too Many Sessions"
  91. aErrors(9) = "Too Many Files"
  92. aErrors(10) = "Too Many Recipients"
  93. aErrors(11) = "Attachment No Found"
  94. aErrors(12) = "Attachment Open Failure"
  95. aErrors(13) = "Attachment Write Failure"
  96. aErrors(14) = "Unknown Recipient"
  97. aErrors(15) = "Bad Recipient"
  98. aErrors(16) = "No Messages"
  99. aErrors(17) = "Invalid Message"
  100. aErrors(18) = "Text Too Large"
  101. aErrors(19) = "Invalid Session"
  102. aErrors(20) = "Type Not Suppported"
  103. aErrors(21) = "Ambiguous Recipient"
  104. aErrors(22) = "Message in Use"
  105. aErrors(23) = "Network Failure"
  106. aErrors(24) = "Invalid Edit Fields"
  107. aErrors(25) = "Invalid Recipient"
  108. aErrors(26) = "Not Supported"
  109. End Sub
  110.  
  111. Public Sub BCCAddressAdd(ByVal strAddress As String)
  112.     RecipientAdd MAPI_BCC, , strAddress
  113. End Sub
  114.  
  115. Public Sub BCCNameAdd(ByVal strName As String)
  116.     RecipientAdd MAPI_BCC, strName
  117. End Sub
  118.  
  119. Public Sub CCAddressAdd(ByVal strAddress As String)
  120.     RecipientAdd MAPI_CC, , strAddress
  121. End Sub
  122.  
  123. Public Sub CCNameAdd(ByVal strName As String)
  124.     RecipientAdd MAPI_CC, strName
  125. End Sub
  126.  
  127. Public Sub MessageIs(ByVal strNoteText As String)
  128.     mM.NoteText = strNoteText
  129. End Sub
  130.  
  131. Public Sub SubjectIs(ByVal strSubject As String)
  132.     mM.Subject = strSubject
  133. End Sub
  134.  
  135. Public Sub ToAddressAdd(ByVal strAddress As String)
  136.     RecipientAdd MAPI_TO, , strAddress
  137. End Sub
  138.  
  139. Public Sub ToNameAdd(ByVal strName As String)
  140.     RecipientAdd MAPI_TO, strName
  141. End Sub
  142.  
  143. Public Sub FileAdd(ByVal strPathName As String)
  144.     Dim f As MAPIFile
  145. With f
  146.     .PathName = StrConv(strPathName, vbFromUnicode)
  147. End With
  148. ReDim Preserve mAf(lAf)
  149. mAf(lAf) = f
  150. lAf = lAf + 1
  151. End Sub
  152.  
  153. Public Sub Send()
  154. Dim r As Long
  155. With mM
  156.     If lAf > 0 Then
  157.         .FileCount = lAf
  158.         .Files = VarPtr(mAf(0))
  159.     End If
  160.     If lAr > 0 Then
  161.         .RecipCount = lAr
  162.         .Recipients = VarPtr(mAr(0))
  163.         r = MAPISendMail(0, 0, mM, 0, 0)
  164.         If r <> 0 Then MsgBox aErrors(r)
  165.     End If
  166. End With
  167. End Sub
  168.  
  169. Private Sub RecipientAdd(ByVal lngType As Long, Optional ByVal strName As String, Optional ByVal strAddress As String)
  170. Dim r As MAPIRecip
  171. r.RecipClass = lngType
  172. If strName <> "" Then r.Name = StrConv(strName, vbFromUnicode)
  173. If strAddress <> "" Then r.Address = StrConv(strAddress, vbFromUnicode)
  174. ReDim Preserve mAr(lAr)
  175. mAr(lAr) = r
  176. lAr = lAr + 1
  177. End Sub
  178.  
  179.  
It could be the nature of the code that it is executed synchronously, meaning all other processes are suspended until current code completion.
Sep 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

40
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...
0
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...
2
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...
1
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...
7
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...
4
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.
15
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...
2
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...
0
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
0
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...
0
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...
1
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)...
0
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
0
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...

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.