473,394 Members | 1,714 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,394 software developers and data experts.

MAPI and attachments

I'm trying to send mail using MAPI in my VB.NET application. Mail message
window opens, but it does't contain recipients and attachments.
My guess is I'm doing something wrong with recip and file arrays. Here is
the code:

Public Structure MapiMessage
Public ulReserved As Integer
Public lpszSubject As String
Public lpszNoteText As String
Public lpszMessageType As String
Public lpszDateReceived As String
Public lpszConversationID As String
Public flFlags As Integer
Public lpOriginator As MapiRecip
Public nRecipCount As Integer
Public lpRecips As Object 'lpMapiRecipDesc
Public nFileCount As Integer
Public lpFiles As Object 'lpMapiFileDesc
End Structure

Public Structure MapiRecip
Public ulReserved As Integer
Public ulRecipClass As Integer
Public lpszName As String
Public lpszAddress As String
Public ulEIDSize As Integer
Public lpEntryID As Object 'lpvoid
End Structure

Public Structure MapiFile
Public ulReserved As Integer
Public flFlags As Integer
Public nPosition As Integer
Public lpszPathName As String
Public lpszFileName As String
Public lpFileType As String 'lpvoid
End Structure

Public Class MAPI
Public Declare Auto Function MapiSendMail Lib "Mapi32.dll" Alias
"MAPISendMail" (ByVal pSession As Integer, ByVal pUIParam As Integer, ByRef
pMsg As MapiMessage, ByVal pFlags As Integer, ByVal pReserved As Integer) As
Integer

Public Sub SendMail(ByVal SendTo As String, ByVal Subject As String,
ByVal Attachment As String)

Dim msg As MapiMessage
Dim recip(1) As MapiRecip
Dim file(1) As MapiFile

recip(0).lpszAddress = "te**@test.com"
recip(0).ulRecipClass = 1
recip(0).lpszName = "Test"
recip(0).ulReserved = 0
recip(0).ulEIDSize = 0
recip(0).lpEntryID = Nothing

file(0).ulReserved = 0
file(0).flFlags = 0
file(0).nPosition = -1
'file(0).lpszPathName = Attachment
'file(0).lpszFileName = Path.GetFileName(Attachment)
file(0).lpszPathName = "C:\temp\test.pdf"
file(0).lpszFileName = "test.pdf"
file(0).lpFileType = Nothing

msg.ulReserved = 0
msg.lpszSubject = "Test subject"
msg.flFlags = 0
msg.lpOriginator = Nothing
msg.lpszConversationID = Nothing
msg.lpszDateReceived = Nothing
msg.lpszMessageType = Nothing
msg.lpszNoteText = "Test message"
msg.lpRecips = recip
msg.nRecipCount = 1
msg.nFileCount = 1
msg.lpFiles = file

Dim MAPIResult As Integer

MAPIResult = MapiSendMail(Nothing, Nothing, msg, 8, Nothing)

End Sub
End Class
Nov 21 '05 #1
0 956

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

Similar topics

0
by: scanner36 | last post by:
I have a working VB6 program using MAPI and Outlook Express which sends and receives Email without problems. I am unable to send Email with attachments. I've tried most examples I've found online and...
1
by: netLynx | last post by:
Hi, I am rewriting code from VB6 using MAPI into VB.NET I need to read an attachment off an email on an Exchange Server. In the old VB6 (not written by me) they restrict the Messages.type to...
2
by: planetthoughtful | last post by:
Hi All, I need to build a console app that can connect to a mailbox on a Microsoft Exchange 2000 Server located on our intranet to do the following: - go through all emails in the inbox -...
3
by: GayathriP | last post by:
This article discusses about how can we access the inbox through MAPI using C# .NET. It also discusses about how to store the attachment in the local directory, how to create a folder in the inbox ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.