• 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 5

Can anyone please post a simple example of calling the dws webservice for creating a folder in sharepoint through its web services?


In addition, an example for user/password along with it would be really nice.


Please help me! Thanx in advance. 

  • September 22, 2009
  • Like
  • 0

The ability to generate and attach a .pdf document to an e-mail generated by an Visualforce Page e-mail template is fairly straightforward using the <messaging:attachment renderAs="pdf"> capability.  However, this method generates a .pdf file from whatever is contained between the <messaging:attachment> and </messaging:attachment> tags.


My problem is that I already have a .pdf document stored in a Documents folder in SFDC and I want to automatically attach that document to an e-mail generated by a Visualforce Page template without the user having to go through the  the document selection and attachment process.  I don't want to have to re-generate the document, just attach it.


Any ideas?

Hello -


I have developed a vf page for our sales team that shows a formatted Forecast for the opportunity. This page is embedded directly on the opportunity object in a colapsable page section called 'Forecast'. There are two buttons on the Forecast page (at the top)- one to preview the forecast in PDF form (a second vf page) and another to "Generate Forecast". This second button takes the user to a screen with a list of potential people to whom they can send the forecast (listed as checkboxes). Once the user selects the people to whom they want to send the Forecast and hit the send button, the Forecast is sent as a PDF attachment on an email to whomever they have selected. As well, the PDF is saved as an attachment on the opportunity.


 My issue is that while my initial tests allowed me to open and view the attachment, I now get an error when I try to open either attachment (from the email, or from the Notes & Attachments area on the opportunity). I know I must have tweaked something that is causing this error but I do not know what? The error is "File does not begin with '%PDF-'"


Any help would be appreciated - this is my first time working with controllers, so it might be something obvious that I am missing. I have attached the code for the page that triggers the creation of the PDF's & email, and the controller associated with it.


Page Code:


<apex:page standardController="Opportunity" Extensions="emailForecast" showHeader="false" sideBar="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockSection >
<apex:outputText value="Please select the people to whom you would like to email your forecast:"/><br/><br/>
<apex:pageblockSectionItem >
<apex:selectCheckboxes value="{!Addresses}" layout="pageDirection" style="text-align:left;">
<apex:selectOptions value="{!items}"/>
<apex:commandButton value="Send" action="{!emailPeople}" status="status" />




public class emailForecast {
ApexPages.StandardController controller;
public Opportunity q {get;set;}
public Opportunity opportunityNo {get;set;}
String op = ApexPages.currentPage().getParameters().get('id');

public emailForecast(ApexPages.StandardController c) {
controller = c;
q = (Opportunity) c.getRecord();}

public PageReference emailPeople() {
String thisOpp = ApexPages.currentPage().getParameters().get('Id');
opportunityNo = [select Opportunity_No__c, NAME,Id,OwnerId,Account.Id from Opportunity where Id = :thisOpp];

//Attach the Forecast to the Notes & Attachments Area
/* Get the page definition */
PageReference ForecastPdfPage = Page.forecast;
/* set the id on the page definition */
/* generate the pdf blob */
Blob ForecastPdfBlob = ForecastPdfPage.getContent();
/* create the attachment against the Opportunity */
Attachment a = new Attachment(parentId = q.id, name=opportunityNo.NAME + '-'+ opportunityNo.Opportunity_No__c+'-'+'Forecast.pdf', body = ForecastPdfBlob);
/* insert the attachment */
insert a;

// Create an email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage ();
// NEED TO FIGURE OUT HOW TO ADD TARGET ID SO WE CAN SAVE TO HISTORY - email.setTargetObjectId(opportunityNo.OwnerId);
email.setSenderDisplayName('New Order');
email.setSubject('New Order Created for Opportunity # ' + opportunityNo.Opportunity_No__c);
email.setPlainTextBody('A new order has been created for ' + opportunityNo.Name +' , '+ opportunityNo.Opportunity_No__c+'. The ERF and SO Approval are attached.');
email.setHtmlBody('A new order has been created for' + '&nbsp;'+'<b>'+ opportunityNo.Name +'&nbsp;'+'</b>'+ opportunityNo.Opportunity_No__c+'. The ERF and SO Approval are attached.'+
' To view this Opportunity <a href=https://na1.salesforce.com/'+ q.Id +'><b>click here</b></a>');

// Create an email attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
// Set name of PDF
// Set body of PDF
// Attach the PDF to your email
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

// Send email & return to Opportunity
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

/* send the user back to the opportunity detail page */
return controller.view();


String[] addresses = new String[]{};

public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('email1@company.com','Person1'));
options.add(new SelectOption('email2@company.com','Person2'));
options.add(new SelectOption('email3@company.com','Person3'));
...(and so on)

return options;
public String[] getAddresses() {
return addresses;
public void setAddresses(String[] addresses) {
this.addresses = addresses;









Message Edited by Slangan on 06-10-2009 10:15 AM
Message Edited by Slangan on 06-10-2009 10:29 AM
Message Edited by Slangan on 06-10-2009 02:18 PM
Does anyone know how to remove a line break from a field?
I am trying to use MailingAddress in a hyperlink formula but it breaks every time there is a contact with a two line mailing address.

I have tried the following and they did not work:

For reference my formula looks something like this:
hyperlink("http://linklocation.com?address="&MailingAddress,"Link Text", "_blank")
I have a written a scontrol which implements the send email functionality.
In that I am able to attach a document already uploaded in Salesforce. But if I need to attach a document that resides on my PC and not in Salesforce, is it possible to do that in a Scontrol?
has anyone worked with salesforce and sharepoint?  i have a prospective client wondering if the two can be integrated for membership managment needs.