Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending html file as attachment using MAPI

Status
Not open for further replies.

gurukrishna

Programmer
Jun 3, 2001
8
IN
hi!! I have a small problem .I am using MAPIin VB to send a report as an attachment. The problem is that although I export the report in HTML format and set attachment type in as
MAPIMessages1.AttachmentType = ATTACHTYPE_HTML
and
MAPIMessages1.AttachmentPathName ="C:\Temp\Daily_Report.htm"

it still sends the file as atext file!!. Any suggestions. Can somebody help please. gotta deadline to meet..
thanx,
gaurav.


PS: the code is enclosed below..

Code begins here
Private Sub cmdEMail_Click()

'MAPI constants from CONSTANT.TXT file:
Const SESSION_SIGNON = 1
Const MESSAGE_COMPOSE = 6
Const ATTACHTYPE_DATA = 0
Const RECIPTYPE_TO = 1
Const RECIPTYPE_CC = 2
Const MESSAGE_RESOLVENAME = 13
Const MESSAGE_SEND = 3
Const SESSION_SIGNOFF = 2

'Open up a MAPI session:
MAPISession1.Action = SESSION_SIGNON
'Point the MAPI messages control to the open MAPI session:
MAPIMessages1.SessionID = frmReportEmail.MAPISession1.SessionID

MAPIMessages1.Action = MESSAGE_COMPOSE 'Start a new message

'Set the subject of the message:
MAPIMessages1.MsgSubject = txtSubject.Text
'Set the message content:



MAPIMessages1.MsgNoteText = txtMessage.Text





'The following four lines of code add an attachment to the message,
'and set the character position within the MsgNoteText where the
'attachment icon will appear. A value of 0 means the attachment will
'replace the first character in the MsgNoteText. You must have at
'least one character in the MsgNoteText to be able to attach a file.
MAPIMessages1.AttachmentPosition = 0
'Set the type of attachment:
MAPIMessages1.AttachmentType = ATTACHTYPE_DATA
'Set the icon title of attachment:
MAPIMessages1.AttachmentName = "Data Report"
'Set the path and file name of the attachment:
MAPIMessages1.AttachmentPathName = "C:\Temp\Daily_Report.htm"

MAPIMessages1.RecipIndex = 0 'First recipient
MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
MAPIMessages1.RecipDisplayName = txtToField.Text 'e-mail name
' MAPIMessages1.RecipIndex = 1 'add a second recipient
' MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
' MAPIMessages1.RecipDisplayName = "TanyaLasagna" 'e-mail name
' MAPIMessages1.RecipIndex = 2 'Add a third recipient
' MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient in CC line
' MAPIMessages1.RecipDisplayName = "BlairAngelHair" 'e-mail name
' MAPIMessages1.RecipIndex = 3 'Add a fourth recipient
' MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient on CC Line
' MAPIMessages1.RecipDisplayName = "JoanieCannelloni" 'e-mail name"



'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
'the recipient address in MapiMessages1.RecipAddress
'If the E-Mail name is not valid, a trappable error will occur.
MAPIMessages1.Action = MESSAGE_RESOLVENAME
'Send the message:
MAPIMessages1.Action = MESSAGE_SEND

'Close MAPI mail session:
MAPISession1.Action = SESSION_SIGNOFF

End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdView_Click()
' Export a report as HTML, overwriting any existing file. Export
' all pages to the Daily_Report.htm file.

DataReport1.Show

End Sub

Private Sub Form_Load()
' Export a report as HTML, overwriting any existing file. Export
' all pages to the Daily_Report.htm file.
DataReport1.ExportReport rptKeyUnicodeHTML_UTF8, "C:\Temp\Daily_Report", True, , _
rptRangeAllPages



End Sub

Code Ends Here
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top