dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

No VB.net Example - ContentDisposition class

Open jbstcyr opened this issue 7 years ago • 4 comments

There are no examples for using with VB.net and C#.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

jbstcyr avatar Oct 20 '18 11:10 jbstcyr

Thanks for your feedback @jbstcyr. This page does have a C# example but it's missing the VB version. We'll add this to our VB parity project at https://github.com/dotnet/docs/projects/77.

mairaw avatar Mar 21 '19 21:03 mairaw

If I'm looking at the right page... the following code is the VB.NET version of the sample.

     Sub CreateMessageInlineAttachment(server As String, attachmentPath As String)

       ' Create a message And set up the recipients.

       Dim message = New MailMessage("[email protected]", "[email protected]", "An inline text message for you.", "Message: ")

       ' Attach the message string to this email message.

       Using data = New Attachment(attachmentPath, MediaTypeNames.Text.Plain)

         ' Send attachmentPath as part of the email body.

         message.Attachments.Add(data)
         data.ContentDisposition.Inline = True

         ' Send the message.
         ' Include credentials if the server requires them.

         Using client = New SmtpClient(server)
           client.Credentials = CredentialCache.DefaultNetworkCredentials
           client.Send(message)
         End Using

       End Using

     End Sub

However, when I use the "pencil" to try to perform the edit. I'm having a hard time finding where exactly the sample should be placed in order to have it submitted for approval. (Yes, I'm a newb with regards to trying to contribute to the docs. ;-) )

So if you don't mind pointing out what I'm missing, I'm trainable. ;-)

Note that I did have to test and confirm that this is working this by modifying the code to use an external third-party email server. (And I should also mention that my C++ is very rusty; but I'm pretty sure the sample is converted properly... as it does function.)

DualBrain avatar Mar 22 '19 00:03 DualBrain

Thanks for your feedback @jbstcyr. This page does have a C# example but it's missing the VB version. We'll add this to our VB parity project at https://github.com/dotnet/docs/projects/77.

I don't think the C# example exists... the sample I'm seeing is C++.

DualBrain avatar Mar 22 '19 00:03 DualBrain

C++ is the default language displayed when VB is not available

Here you can see the samples being referenced: https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Net.Mime/ContentDisposition.xml#L49

You can replace that ~/samples/ in the beginning with https://github.com/dotnet/samples/blob/master/

So this is the C# version: https://github.com/dotnet/samples/blob/master/snippets/csharp/VS_Snippets_Remoting/NCLMailSync/CS/mail.cs

So you could add the VB version to the following path: https://github.com/dotnet/samples/blob/master/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/VB/mail.vb

mairaw avatar Mar 22 '19 00:03 mairaw