473,799 Members | 3,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to send email attachments using WebDAV coding in VB .NET?

2 New Member
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.
Mar 27 '06 #1
6 17110
ErwinF
2 New Member
Option Explicit On
Option Strict On

Module Module1

Public Sub Main()

' Variables.
Dim PUTRequest As System.Net.Http WebRequest
Dim PUTResponse As System.Net.Http WebResponse
Dim MOVERequest As System.Net.Http WebRequest
Dim MOVEResponse As System.Net.Http WebResponse
Dim MyCredentialCac he As System.Net.Cred entialCache
Dim strMailboxURI As String
Dim strSubURI As String
Dim strTempURI As String
Dim strServer As String
Dim strPassword As String
Dim strDomain As String
Dim strAlias As String
Dim strTo As String
Dim strSubject As String
Dim strText As String
Dim strBody As String
Dim PUTRequestStrea m As System.IO.Strea m
Dim bytes() As Byte

Try
' Initialize variables.
strServer = "192.168.0. 1"
strPassword = "-"
strDomain = "techdomain "
strAlias = "Administra tor"
strTo = "testfolder@tec hdomain.com"
strSubject = "WebDAV message test"
strText = "This message was sent using WebDAV"

' Build the mailbox URI.
strMailboxURI = "http://" & strServer & "/public/testfolder/"

' Build the submission URI for the message. If Secure
' Sockets Layer (SSL) is set up on the server, use
' "https://" instead of "http://".
'strSubURI = "http://" & strServer & "/public/testfolder/" & "/##DavMailSubmis sionURI##/"
strSubURI = "http://" & strServer & "/public/testfolder/" & "123/Test.eml"

' Build the temporary URI for the message. If SSL is set
' up on the server, use "https://" instead of "http://".
strTempURI = "http://" & strServer & "/public/testfolder/" & _
strSubject & ".eml"

' Construct the RFC 822 formatted body of the PUT request.
' Note: If the From: header is included here,
' the MOVE method request will return a
' 403 (Forbidden) status. The From address will
' be generated by the Exchange server.

strBody = "From: Some One <someone@exampl e.com>" & vbNewLine & _
"MIME-Version: 1.0" & vbNewLine & _
"Content-Type: multipart/mixed;" & vbNewLine & _
" boundary = ""XXXXbound ary text""" & vbNewLine & _
vbNewLine & _
"This is a multipart message in MIME format." & vbNewLine & _
vbNewLine & _
"--XXXXboundary text" & vbNewLine & _
"Content-Type: text/plain" & vbNewLine & _
vbNewLine & _
"this is the body text 2" & vbNewLine & _
vbNewLine & _
"--XXXXboundary text" & vbNewLine & _
"Content-Type: text/plain;" & vbNewLine & _
"Content-Disposition: attachment;" & vbNewLine & _
" filename = ""test.txt" "" & vbNewLine & _
vbNewLine & _
"this is the attachment text" & vbNewLine & _
vbNewLine & _
"--XXXXboundary text--" & vbNewLine

' Create a new CredentialCache object and fill it with the network
' credentials required to access the server.
MyCredentialCac he = New System.Net.Cred entialCache
MyCredentialCac he.Add(New System.Uri(strM ailboxURI), _
"NTLM", _
New System.Net.Netw orkCredential(s trAlias, strPassword, strDomain) _
)

' Create the PUT HttpWebRequest object.
PUTRequest = CType(System.Ne t.WebRequest.Cr eate(strTempURI ), _
System.Net.Http WebRequest)

' Add the network credentials to the request.
PUTRequest.Cred entials = MyCredentialCac he

' Specify the PUT method.
PUTRequest.Meth od = "PUT"

' Encode the body using UTF-8.
bytes = System.Text.Enc oding.UTF8.GetB ytes(strBody)

' Set the content header length. This must be
' done before writing data to the request stream.
PUTRequest.Cont entLength = bytes.Length

' Get a reference to the request stream.
PUTRequestStrea m = PUTRequest.GetR equestStream()

' Write the message body to the request stream.
PUTRequestStrea m.Write(bytes, 0, bytes.Length)

' Close the Stream object to release the connection
' for further use.
PUTRequestStrea m.Close()

' Set the Content-Type header to the RFC 822 message format.
PUTRequest.Cont entType = "message/rfc822"

' PUT the message in the Drafts folder of the
' sender's mailbox.
PUTResponse = CType(PUTReques t.GetResponse() , System.Net.Http WebResponse)

Console.WriteLi ne("Message successfully PUT to " & strTempURI)

' Create the MOVE HttpWebRequest object.
MOVERequest = CType(System.Ne t.WebRequest.Cr eate(strTempURI ), _
System.Net.Http WebRequest)

' Add the network credentials to the request.
MOVERequest.Cre dentials = MyCredentialCac he

' Specify the MOVE method.
MOVERequest.Met hod = "MOVE"

' Set the Destination header to the
' mail submission URI.
MOVERequest.Hea ders.Add("Desti nation", strSubURI)

' Send the message by moving it from the Drafts folder of the
' sender's mailbox to the mail submission URI.
MOVEResponse = CType(MOVEReque st.GetResponse( ), System.Net.Http WebResponse)

Console.WriteLi ne("Message successfully sent to " & strTo)

' Clean up.
PUTResponse.Clo se()
MOVEResponse.Cl ose()

Catch ex As Exception

' Catch any exceptions. Any error codes from the PUT
' or MOVE method requests on the server will be caught
' here, also.
Console.WriteLi ne(ex.Message)

End Try

End Sub

End Module
Mar 27 '06 #2
funnycoder
1 New Member
Hello,

I'm trying to create a draft email using WEBDAV on the exchange server but when I view the message in OWA it shows that it has been already sent and I cannot edit the draft.

Does anyone know why it appears as already sent? How can I fix it so that the draft message shows as unsent so I can edit the draft in OWA?

Thanks
Jul 25 '06 #3
anjalisharma
1 New Member
Hello,

I'm trying to create a draft email using WEBDAV on the exchange server but when I view the message in OWA it shows that it has been already sent and I cannot edit the draft.

Does anyone know why it appears as already sent? How can I fix it so that the draft message shows as unsent so I can edit the draft in OWA?

Thanks
After getting response from the put request donot create the move request object. The move request sends the email.
Mar 19 '07 #4
Rerkah
1 New Member
Hello,

I'm trying to create a draft email using WEBDAV on the exchange server but when I view the message in OWA it shows that it has been already sent and I cannot edit the draft.

Does anyone know why it appears as already sent? How can I fix it so that the draft message shows as unsent so I can edit the draft in OWA?

Thanks
Did you ever get this to work? One person suggested not doing the move request, but this still leaves the message uneditable in your DRAFTS folder. I'm also trying to put a message in the DRAFTS folder that is editable for someone to manually send. Any help would be great, thanks!
Sep 1 '07 #5
zaidlig
45 New Member
Use PROPPATCH instead of PUT. It will create an editable email that can edited in OWA by calling up the URL.
Jan 10 '08 #6
AnaSimjanoski
2 New Member
I think that the solution given here might be what you are looking for:

http://www.independentsoft.de/webdav...ndmessage.html
Dec 16 '10 #7

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

Similar topics

11
12094
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to use PHP to get inside an OWA (Microsoft Outlook Web Access) website to send email that way? The reason I ask is because my corporate office is going to do away with our rogue SMTP server access and force everything through Exchange
0
1476
by: Andrew Pasetti | last post by:
Hello, There is a document on msdn that describes how to send an email using webdav and vb.net (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_esdk_sending_a_message_webdav.asp). However, it does not mention how to add attachments to the message. Perhaps someone can suggest how to add an attachment to the message. Your advice will be greatly appreciated.
1
3056
by: Paul | last post by:
I am using a windows service which accesses Microsoft Outlook. Outlook is supposed to send an email. This works fine when not run in a windows service. I am running the service under my user domain logon. I am using VB.net and using redemption.dll to bypass the security patch. This is the line of code that causes the event error Dim olApp As New Outlook.Application When I try and use a service the following error occurs.
1
47519
by: Michele | last post by:
Hi, I need to send the same Email to different people. I'm using Outlook XP and VB.Net. I tryed with the following code: Dim oOutL As Outlook.Application Dim oMail As Outlook._MailItem oOutL = CreateObject("outlook.application") For i = 0 To Email.Length - 1
8
17064
by: John Brock | last post by:
I am currently using a VB.NET program to send out e-mails with plain text bodies (plus one attachment). The emails are being received as Rich Text messages (probably just my personal Outlook default, because I didn't do this in the program), but there is no actual formatting (italics, color, etc.) in the message body, which is passed to from VB.NET to Outlook as an unformatted text String. I want to start applying formatting to the...
2
2500
by: Robert Dufour | last post by:
I tried using (vs2003 Vb.Net) Public Sub SendEmail( _ ByVal Recipient As String, _ ByVal Sender As String, _ ByVal Subject As String, _ ByVal Message As String, _
2
6027
by: Joe George | last post by:
Hi there, How to save email attachments, from exchange, using WebDAV in C#.NET? Sample code please................... Thanks for your help. -- Joe George
2
2651
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import easyemail smtpserver=easyemail.server('something') smtpserver.login('usr@gmail.com', pwd) newletter=smtpsever.letter(smtpserver) newletter.sendto= newletter.sendcc=
1
2418
by: Chitu03 | last post by:
Hi I am already send a mail using Php with some attachement into it. My Problem is the attachement file is in my Database(mysql). I don't know how can i get from database and then add to my mail. <?php function send_mail($emailaddress, $fromaddress, $emailsubject, $body, $ccaddress, $attachments=false) { $eol="\r\n"; $mime_boundary=md5(time()); # Common Headers $headers .= 'From:...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.